Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, I use asp.net C#
I have table contain

(question
option1
option 2
option3
answer)

I put question with options in data list from database
but i face a problem
how can I access radio button in data list?

and check if the radio button checked is true or false
by match the radio with answer field

What I have tried:

i try this code to check the radio button, but i see when i checked radio button 2 it is work only.
i want to match the checked with database !!

int total=0;
for (int i = 0; i < 3; i++)
{
RadioButton rbtnlist = (RadioButton)DataList1.Items[i].FindControl("RadioButton2");
if (rbtnlist.Checked)
{
total = total + 1;
}
}
Label2.Text = total.ToString();
Posted
Comments
Karthik_Mahalingam 2-Apr-16 6:34am    
what issue you are facing?
Member 12429731 2-Apr-16 6:40am    
how can i match the radiobutton which checked with answer field from database?
Karthik_Mahalingam 2-Apr-16 8:24am    
if (rbtnlist.Checked)
{
if( dbvalue == rbtnlist.Text ) { // your code}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900