Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
RadioButtonList r = default(RadioButtonList);
		r = (RadioButtonList)v.FindControl("RadioButtonList1");
		r.Items.Clear();
		
       r.Items.Add(dt.Rows[ctr]["choice1"]);
       r.Items.Add(dt.Rows[ctr]["choice1"]);
        r.Items.Add(dt.Rows[ctr]["choice3"]);
        r.Items.Add(dt.Rows[ctr]["choice4"]);
       dt.Rows[ctr]["selected"]=r.SelectedIndex;

        



		Session["ctr"] = ctr;
	}

I got the error r.Items.Add(dt.Rows[ctr]["choice1"]);


Thank u for your valuable replay
Posted
Updated 5-Nov-11 2:21am
v2
Comments
AditSheth 5-Nov-11 8:27am    
what is the value of ctr.
P.Salini 5-Nov-11 8:27am    
What is the error you got?

1 solution

Their can be multiple issues with your code.

Few which I can see are as below.

1) Delcare object of RadioButtonList as below.
C#
RadioButtonList r = new RadioButtonList();


2) Use below syntax while adding Items.
C#
r.Items.Add(dt.Rows[ctr]["choice1"].ToString());


Also debug your code and check your dt is not null and has Rows in it.
 
Share this answer
 
Comments
koolprasad2003 5-Nov-11 8:57am    
Nice ans. raiskazi. 5!
RaisKazi 5-Nov-11 9:08am    
Thank you Prasad. :)
Amir Mahfoozi 6-Nov-11 2:02am    
+5
RaisKazi 6-Nov-11 2:06am    
Thank you Amir. :)

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