有个小问题请教下各位大虾,我要根据 DropDownList 控件 里面的值发生变化时来操作其它的东西,请问写在哪个事件里面呢?比如:
<asp:DropDownList ID="dlLeaveReason" runat="server" CssClass="textBoxCss">
                        <asp:ListItem>事假</asp:ListItem>
                        <asp:ListItem>病假</asp:ListItem>
                        <asp:ListItem>调休</asp:ListItem>
                        <asp:ListItem>其它</asp:ListItem>
                    </asp:DropDownList>我想选择“其它”的时候来显示一个TextBox,该写在 DropDownList 的哪个事件里?

解决方案 »

  1.   

    好像还要开启 AutoPostBack="True"
    你试试就知道了
      

  2.   

    在SelectedIndexChanged事件中
     判断额, 你给Item绑定Value值吧,
       根据value判断 ,如果条件满足你的  其它 ,
      那就让textbox显示。
      

  3.   


    protected void dlLeaveReason_SelectedIndexChanged(object sender, EventArgs e)
    {
        if("其它".Equals(Convert.ToString(this.dlLeaveReason.SelectedItem).Trim()))
        {    }
    }<asp:DropDownList ID="dlLeaveReason" runat="server" CssClass="textBoxCss" AutoPostBack="True" OnSelectedIndexChanged="dlLeaveReason_SelectedIndexChanged">
    <asp:ListItem>事假</asp:ListItem>
    <asp:ListItem>病假</asp:ListItem>
    <asp:ListItem>调休</asp:ListItem>
    <asp:ListItem>其它</asp:ListItem>
    </asp:DropDownList>