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();
- }