Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing a online exam project. For the option i took a radiobutton list and binding it dynamically.
The problem is that when i use the selected index property of radiobuttonlist, it is not giving it correct value on selecting a option.
Here is my code behind code:


C#
sql = "select Question_no,Question ,Option1,Option2,Option3,Option4,Question_Image from Contact2 where Question_no=" + nextq + "";
            ds = cn.SelectDS(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {

                lblqno.Text = ds.Tables[0].Rows[0]["Question_no"].ToString();
                lblqstn.Text = ds.Tables[0].Rows[0]["Question"].ToString();
                RadioButtonList1.ClearSelection();
                RadioButtonList1.Items.Clear();
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option1"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option2"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option3"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option4"].ToString());
                Image1.ImageUrl = ds.Tables[0].Rows[0]["Question_Image"].ToString();
            }


Please help me
Posted

1 solution

Set AutoPostBack property of RadioButtonList to True.
 
Share this answer
 

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