如何获得嵌套在DataList中RadioButtonList控件的SelectedIndexChanged事件?

解决方案 »

  1.   

    请参考以下代码1.在ASPX页面添加如下代码:
    <FooterTemplate>
      <asp:TextBox id="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
    </FooterTemplate>
    2.在PAGE_LOAD里面添加如下语句
    TextBox mytxt = (TextBox)this.myGrid.Controls[0].Controls[this.myGrid.Controls[0].Controls.Count-1].FindControl("TextBox1");
    mytxt.TextChanged += new System.EventHandler(this.mytxt_TextChanged);3.在后台添加如下事件代码
    private void mytxt_TextChanged(object sender, System.EventArgs e)
    {
      this.Response.Write("<script>alert('响应了');</script>");
      this.Response.End();
    }同时,你必须保证你页面中有一个按钮,否则它不会提交.
    如此,当在输入框里面回车时,则自动响应上述事件代码.
     
      

  2.   

    没看明白。
    RadioButtonList控件有SelectedIndexChanged事件,可是该控件嵌套到DataList中就找不到这个事件了,这可该怎么办?
      

  3.   

    试着把SelectedIndexChanged()中的内容写到DataList的ItemCommand()事件里面!