set radio button item text dynamically

The following code is the create two items dynamically for a radio button.  How can I set the display text as STATE LEVEL and CITY LEVEL without the dashes?  Thanks.

            Report_level.Items.Add("STATE_LEVEL")
            Report_level.Items.Add("CITY_LEVEL")

ewang1205Asked:
Who is Participating?
 
sachitjainConnect With a Mentor Commented:
No man u just need to remove it through its index like

Report_level.Items.RemoveAt(1);
Above step would delete second item from list.

If u want to delete through item then u have to follow these steps:

ListItem item1 = new ListItem("State Level","STATE_LEVEL");
ListItem item2 = new ListItem("City Level","CITY_LEVEL");

Report_level.Items.Add(item1);
Report_level.Items.Add(item2);

Report_Level.Items.Remove(item2);

Regards
Sachit.
0
 
sachitjainCommented:
Report_level.Items.Add(new ListItem("State Level","STATE_LEVEL"));
Report_level.Items.Add(new ListItem("City Level","CITY_LEVEL"));

In ListItem constructor, two parameters passed are value and name pair.
I hope it works.

Regards
Sachit Jain
0
 
sachitjainCommented:
Let me correct myself....
In ListItem constructor, two parameters passed are text and value.

Regards
Sachit.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
ewang1205Author Commented:
I like the text to be STATE LEVEL and value to be STATE_LEVEL.  How to do that?  Thanks.
0
 
ewang1205Author Commented:
I see the value and text now.  Let me try and update the results.  Thanks.

Report_level.Items.Add(new ListItem("State Level","STATE_LEVEL"));
Report_level.Items.Add(new ListItem("City Level","CITY_LEVEL"));
 
0
 
ewang1205Author Commented:
Thanks.  Works great.  Now if I need to remove the list, will the following work?  


Report_level.Items.Remove(new ListItem("State Level","STATE_LEVEL"));
Report_level.Items.Remove(new ListItem("City Level","CITY_LEVEL"));
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.