Hi sunil,
i am explaining your question through a sample example.
in markup:
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="style1">
<tr>
<td colspan="2">
<h3>
Sample Registraion</h3>
</td>
</tr>
<tr>
<td class="style3">
Name:</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
Email</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
Gendere</td>
<td>
<asp:RadioButtonList ID="rbtGender" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td align="center" class="style2" colspan="2">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
</td>
</tr>
<tr>
<td align="center" class="style2" colspan="2">
<asp:Label ID="lblmsg" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
in code bind:
protected void Button1_Click(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["srinivasdb"].ConnectionString;
SqlConnection cn = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into GenderSample values(@Name,@Email,@Gender)";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@gender", rbtGender.SelectedValue);
if (cn.State == ConnectionState.Closed)
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
lblmsg.Text = "Data entered successfully!!!";
}<pre>
I hope this example clears your problem.
Have a good day!!!