TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
john kanyora
NA
242
46.5k
how to use a loop with radiobutton to retrieve data
Feb 23 2018 2:27 AM
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();
}
Reply
Answers (
7
)
dropdownlist attributes onchange event not firing to js
How to read session value in Controller in MVC