Click here to Skip to main content
15,917,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to add radio button list items dynamically with code and i got this error:

'System.Web.UI.WebControls.RadioButton' does not contain a definition for 'Items'and no extension method 'Items' accepting a first argument of type 'System.Web.UI.WebControls.RadioButton' could be found (are you missing a using directive or an assembly reference?)
my code is:
<asp:RadioButton ID="lstBorder" runat="server" Width="177px" Height="59px" />


protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ListItem item = new ListItem();
item.Text = BorderStyle.None.ToString();
item.Value = ((int)BorderStyle.None).ToString();
lstBorder.Items.Add(item);
}
}

I would appreciate if you could help me. I even didnt get the part if Items is not a property in radio button list? how could i fix it?
Posted

1 solution

I think u have to use radiobuttonlist instead of radiobutton
check below link it has property items

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist(v=vs.110).aspx[^]
 
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