Home > ASP.Net > How to Use HTML RadioButton Inside Gridview

How to Use HTML RadioButton Inside Gridview

Hi all,

try this example to use HTML RadioButton inside Gridview row and get Selected value from Code behind

<asp:GridView ID="GridView1" runat="server"
 AutoGenerateColumns="False" BackColor="White"
 BorderColor="#CC9966" BorderStyle="None"
 BorderWidth="1px" CellPadding="4" Font-Names="Verdana">
 <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
 <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" />
 <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" />
 <asp:BoundField DataField="Description" HeaderText="Description" />
 <asp:TemplateField HeaderText="Select One">
 <input name="MyRadioButton" type="radio"
 value='<%# Eval("CategoryID") %>' />
 <RowStyle BackColor="White" ForeColor="#330099" />
 <SelectedRowStyle BackColor="#FFCC66"
 Font-Bold="True" ForeColor="#663399" />
 <PagerStyle BackColor="#FFFFCC"
 ForeColor="#330099" HorizontalAlign="Center" />
 <HeaderStyle BackColor="#990000"
 Font-Bold="True" ForeColor="#FFFFCC" />

In code behind to get selected value

protected void Button1_Click(object sender, EventArgs e)
 string selectedValue = Request.Form["MyRadioButton"];
 lblMsg.Text = selectedValue;

Hope this helps

Good Luck.

Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: