Multiple Radiobuttons in gridview
ASPX :
<asp:TemplateField Visible="true" HeaderText ="Strongly Disagree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn1" runat ="server" />--%>
<input name="MyRadioButton1" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Agree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn2" runat ="server" />--%>
<input name="MyRadioButton2" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Disagree">
<ItemTemplate>
<%--<asp:RadioButton ID="rdbtn3" runat ="server" />--%>
<input name="MyRadioButton3" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Strongly Agree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn4" runat ="server" />--%>
<input name="MyRadioButton4" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
C# :
protected void btnSubmit_Click(object sender, EventArgs e)
{
string selectedValue = Request.Form["MyRadioButton1"];
lblMsg.Text = selectedValue;
//same for next RadioButton also ....
}
<asp:TemplateField Visible="true" HeaderText ="Strongly Disagree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn1" runat ="server" />--%>
<input name="MyRadioButton1" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Agree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn2" runat ="server" />--%>
<input name="MyRadioButton2" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Disagree">
<ItemTemplate>
<%--<asp:RadioButton ID="rdbtn3" runat ="server" />--%>
<input name="MyRadioButton3" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText ="Strongly Agree">
<ItemTemplate>
<%-- <asp:RadioButton ID="rdbtn4" runat ="server" />--%>
<input name="MyRadioButton4" type ="radio" value = "'<%# Eval("SQTN_NO") %>'" />
</ItemTemplate>
</asp:TemplateField>
C# :
protected void btnSubmit_Click(object sender, EventArgs e)
{
string selectedValue = Request.Form["MyRadioButton1"];
lblMsg.Text = selectedValue;
//same for next RadioButton also ....
}
Comments
Post a Comment