Radio Button OnCheckedChanged() event is not called
-
Hello everyone, I have a gridview,in which each row populates a question with its answers(as radio buttons). I have to execute some code on radio button's OnCheckedChanged event.Somehow,on its OnCheckedChanged event,page is postbacked but it is not going to OnCheckedChanged() method.Can anyone give any suggestions for how can I achieve this? The code looks somewhat like this :
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView ID="GridView1" OnRowDataBound="GridView1_OnRowDataBound" AutoGenerateColumns="false"
runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" AutoGenerateColumns="false" runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" /></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
-
Hello everyone, I have a gridview,in which each row populates a question with its answers(as radio buttons). I have to execute some code on radio button's OnCheckedChanged event.Somehow,on its OnCheckedChanged event,page is postbacked but it is not going to OnCheckedChanged() method.Can anyone give any suggestions for how can I achieve this? The code looks somewhat like this :
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView ID="GridView1" OnRowDataBound="GridView1_OnRowDataBound" AutoGenerateColumns="false"
runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" AutoGenerateColumns="false" runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" /></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
Clean Solution and then Rebuild.
-
Clean Solution and then Rebuild.
Thanx for your reply,but I have already tried doing this. In fact,I created a separate project just to check whether it works or not,but it still failed. The same method I called on a button's OnClick & it worked but it didn't work for RadioButton's OnCheckedChanged().
-
Hello everyone, I have a gridview,in which each row populates a question with its answers(as radio buttons). I have to execute some code on radio button's OnCheckedChanged event.Somehow,on its OnCheckedChanged event,page is postbacked but it is not going to OnCheckedChanged() method.Can anyone give any suggestions for how can I achieve this? The code looks somewhat like this :
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView ID="GridView1" OnRowDataBound="GridView1_OnRowDataBound" AutoGenerateColumns="false"
runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" AutoGenerateColumns="false" runat="server">
<Columns>
asp:TemplateField
<ItemTemplate>
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" /></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
Since you have defined the control inside grid u have to create the checked event, ex- <asp:GridView ID="grdSearch" runat="server" Width="100%"> <Columns> <asp:TemplateField HeaderText="FirstName"> <ItemTemplate> <asp:LinkButton ID="lbtnFName" runat="server" Text='<%# eval("fname") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> Code behind- Protected Sub grdSearch_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdSearch.RowCreated Dim LinkButton1 As LinkButton Select Case e.Row.RowType Case DataControlRow