Adding List Items with a Collection Editor
In C#, you can add items to a RadioButtonList control using the Collection Editor. Follow these steps:
Click on the RadioButtonList control to select it.
In the Properties window, find the Items property and click on the ellipsis button (…).
This will open the String Collection Editor. Click on the Add button to add a new item to the list.
Type the text for the item in the Value field.
If you want to assign a different value to the item, enter it in the Text field.
Repeat steps 3-5 for each item you want to add.
Click OK to close the editor and save the changes.
Alternatively, you can add items to a RadioButtonList control programmatically using C# code.
Here’s an example:
RadioButtonList radioButtonList = new RadioButtonList();
radioButtonList.Items.Add(new ListItem(“Item 1”, “1”));
radioButtonList.Items.Add(new ListItem(“Item 2”, “2”));
radioButtonList.Items.Add(new ListItem(“Item 3”, “3”));
This code creates a new RadioButtonList control and adds three items to it. Each item is created using the ListItem class, with the first parameter being the text to display and the second parameter being the value of the item.
Apply for ASP.NET Certification Now!!
https://www.vskills.in/certification/certified-aspnet-programmer