how use radio button in

Total Post:18


 11059  View(s)
Rate this:
sir i want to use radiobutton in .aspx page. and i want to save checked radiobutton data in table.
example-i have take a field like  Sex-(1-Male,2-Female),then i want to saved data in table which is checked
  1. Re: how use radio button in

    Write down following code on aspx page

            <asp:RadioButton ID="rdbMale" GroupName="Gender" Text="Male" runat="server" />
            <asp:RadioButton ID="rdbFemale" GroupName="Gender" Text="Female" runat="server" />
            <asp:Button ID="btnSave" Text="Save Radio Button State" runat="server" OnClick="btn_Click" />
    Write down following code on code behind file.
    protected void btn_Click(object sender, EventArgs e)
            string gender = "";
            if (rdbMale.Checked)
                gender = rdbMale.Text;
                gender = rdbFemale.Text;
            using (SqlConnection con = new SqlConnection("conString"))
                SqlCommand cmd = new SqlCommand("insert into gender values(@gender)", con);
                cmd.Parameters.Add(new SqlParameter("@gender", gender));
                Response.Write("<script>alert('Status Saved')</script>");
    This might be worked for you.

      Modified On Mar-29-2018 03:58:13 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.