您的位置:首页 > 其它

有SelectedIndexChanged事件的控件的刷新问题-需要点击两下才能刷新的问题

2009-09-13 02:32 471 查看
对于有SelectedIndexChanged事件的控件,在这个事件的处理语句最后要加上
重新绑定的语句,才能刷新,否则要点击两下。
例如
<asp:DropDownList ID="DropDownListParentCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListParentCategory_SelectedIndexChanged" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="-1">==请选择==</asp:ListItem>
<asp:ListItem Value="0">图书商品类</asp:ListItem>
<asp:ListItem Value="1">网站文章类</asp:ListItem>
</asp:DropDownList>
在其事件中,如不添加
DropDownListParentCategory.DataBind();语句,则需要点击两下才能刷新。
protected void DropDownListParentCategory_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownListParentCategory.DataBind();
}

此内容适合于任何有SelectedIndexChanged事件的控件。例如DataList
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐