Hi, kindly requesting to be assisted on how to use radiobuttons to retrieve data from a table in the database. i have three radiobuttons, such that once the user selects one the data is retrieved from a table to the gridview and if the other is selected the same happens.
this is my .aspx code containing the radiobutton.
- <asp:RadioButtonList ID="Radiobuttonlist1" OnCheckedChange="Radiobuttonlist1_CheckedChange" runat="server">
- <asp:ListItem Text="Patients" Value="Patients">asp:ListItem>
- <asp:ListItem Text="Suppliers" Value="Suppliers">asp:ListItem>
- <asp:ListItem Text="Employees" Value="Employees">asp:ListItem>
- asp:RadioButtonList>
- <asp:GridView ID="GridView1" runat="server" />
this is my code behind which i have just created only for one radiobutton..kindly help on how to implement the loop.
- protected void radioButton1_CheckedChanged(Object sender, EventArgs e)
- {
- string connect = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;
- SqlConnection conn = new SqlConnection(connect);
- conn.Open();
- SqlCommand cmd = new SqlCommand("select PatientName,PatientCellPhone from CustomerInformation where SampleColumn='"+radiobutton1.value.Text + "';",conn);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- da.Fill(ds);
- conn.Close();
- GridView1.DataSource = ds;
- GridView1.DataBind();
- }
Nitin SontakkePosted Feb 23, 2018, 6:29 AM
john kanyoraPosted Feb 23, 2018, 6:34 AM
john kanyoraPosted Feb 23, 2018, 4:00 AM
Rajneesh ChaubeyPosted Feb 23, 2018, 3:55 AM
john kanyoraPosted Feb 23, 2018, 3:20 AM
john kanyoraPosted Feb 23, 2018, 3:07 AM
Rajneesh ChaubeyPosted Feb 23, 2018, 2:57 AM