How to make update function with RadioButton.
Code
namespace Mob_del_dtls
{
public partial class update : System.Web.UI.Page
{
int empno = 0;
protected void Page_Load(object sender, EventArgs e)
{
empno = Convert.ToInt32(Request.QueryString["Id"].ToString());
Session["EmpId"] = empno;
if (!IsPostBack)
{
BindTextBoxvalues();
}
}
private void BindTextBoxvalues()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
// SqlCommand cmd = new SqlCommand("select * from ts4", con);
SqlCommand cmd = new SqlCommand("select * from mbl_usg_dtl where Id=" + empno, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
txtEmpId.Text = dt.Rows[0][0].ToString();
//txt1.Text = dt.Rows[0][1].ToString();
Label9.Text = dt.Rows[0][1].ToString();
Label8.Text = dt.Rows[0][2].ToString();
Label7.Text = dt.Rows[0][3].ToString();
Label1.Text = dt.Rows[0][4].ToString();
Label2.Text = dt.Rows[0][5].ToString();
Label3.Text = dt.Rows[0][6].ToString();
Label4.Text = dt.Rows[0][7].ToString();
Label5.Text = dt.Rows[0][8].ToString();
Label6.Text = dt.Rows[0][9].ToString();
//txt11.Text = dt.Rows[0][10].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
string vrfd = string.Empty;
string rmk = txt9.Text.Trim();
if (RadioButton1.Checked)
{
vrfd = "YES";
}
if (RadioButton2.Checked)
{
vrfd = "NO";
}
string conn = "";
conn = ConfigurationManager.ConnectionStrings["constr"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();
SqlCommand cmd = new SqlCommand("Update mbl_usg_dtl set vrfd='" + RadioButton1.Text + "' ,rmk='" + txt9.Text + "'where Id='" + txtEmpId.Text + "'", objsqlconn);
cmd.ExecuteNonQuery();
{
Response.Redirect("Index.aspx");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("index.aspx");
}
}
}
<body style="background-color: powderblue;">
<form id="form2" runat="server">
<div class="auto-style13">
<table align="center" border="1" class="auto-style30">
<tr>
<td align="center" class="auto-style29" colspan="4">
<span class="auto-style20"><strong>Mobile Usage Decleartion </strong></span><strong>
<br class="auto-style20" />
</strong>
</td>
</tr>
<tr>
<td class="auto-style12">SL.No</td>
<td class="auto-style11" colspan="3">
<asp:Label ID="txtEmpId" runat="server" Text="Label" CssClass="auto-style19"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12">Emp. Id</td>
<td class="auto-style26">
<asp:Label ID="Label9" runat="server" Text="Label"></asp:Label>
</td>
<td class="auto-style28">Emp. Name
</td>
<td class="auto-style7">
<asp:Label ID="Label8" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12">Mobile Numaber</td>
<td class="auto-style26" colspan="3">
<asp:Label ID="Label7" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12"><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Bill Date Form</span></td>
<td class="auto-style7" colspan="3">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td class="auto-style22"><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Bill Date To</span></td>
<td class="auto-style21" colspan="3">
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12">Invoice No</td>
<td class="auto-style7" colspan="3">
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12"><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Invoice Date</span></td>
<td class="auto-style7" colspan="3">
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12"><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Location</span></td>
<td class="auto-style11" colspan="3">
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style12"><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Verified By</span></td>
<td class="auto-style11" colspan="3">
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style17"><span style="font-family: Arial; font-size: large; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;" class="auto-style18">Verified</span></td>
<td class="auto-style27">
<asp:RadioButton ID="RadioButton1" runat="server" Text="Yes" GroupName="feedback" CssClass="auto-style27" />
</td>
<td class="auto-style11" colspan="2">
<asp:RadioButton ID="RadioButton2" runat="server" Text="No" GroupName="feedback" CssClass="auto-style27" />
</td>
</tr>
<tr>
<td class="auto-style17"><span style="font-family: Arial; font-size: large; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(176, 224, 230); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;" class="auto-style18">Remark</span></td>
<td class="auto-style11" colspan="3">
<asp:TextBox ID="txt9" Height="67px" Width="314px" runat="server" CssClass="auto-style16"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style17"> </td>
<td class="auto-style11" colspan="3"> </td>
</tr>
<tr>
<td colspan="4">
<font color="White" size="1">
<span class="style1"> <asp:Button ID="Button1" runat="server" Text="Update" OnClick="Button1_Click" Width="110px" CssClass="auto-style31" Height="26px" />
<asp:Button ID="Button2" runat="server" Text="Back" OnClick="Button2_Click" Width="110px" CssClass="auto-style31" Height="26px" />
</span>
</font>
</td>
</tr>
</form>