add list items to dropdowlist [modified]
-
Hi, I have a dropdownlist that gets populated programmatically from a datasource. However, depending if the user is a admin user, I want to add 2 more list items to the Here is my code on how I add the list items programmatically to that list:
drpStatus.Items.Add("Admin") drpStatus.Items.Add("Global")
Problem with my code is, the value and display of the list item is the same. My value and display text differ. I need to have something like(excuse the code, but it does not render correctly when posted: How can I do this? -
Hi, I have a dropdownlist that gets populated programmatically from a datasource. However, depending if the user is a admin user, I want to add 2 more list items to the Here is my code on how I add the list items programmatically to that list:
drpStatus.Items.Add("Admin") drpStatus.Items.Add("Global")
Problem with my code is, the value and display of the list item is the same. My value and display text differ. I need to have something like(excuse the code, but it does not render correctly when posted: How can I do this? -
playout wrote:
something like:
Something like what? If you are using html tags then check the box "ignore HTML tags in this message (good for code snippets)"
Best Regards, Apurva Kaushal
-
OK i think you want to add value also if i am not wrong try this ListItem items = new ListItem("Admin", "A"); or you can do this way also ListItem items = new ListItem(); items.Text = "Global"; items.Value = "G"; Add to the DropDownList DropDownList1.Items.Add(items); Is it fine ? Send your reply
-
you can do it like this: ListItem li = new ListItem("test3,t); ddl.Items.Add(li);
Best Regards, Apurva Kaushal
-
OK i think you want to add value also if i am not wrong try this ListItem items = new ListItem("Admin", "A"); or you can do this way also ListItem items = new ListItem(); items.Text = "Global"; items.Value = "G"; Add to the DropDownList DropDownList1.Items.Add(items); Is it fine ? Send your reply
-
Hi, I have a dropdownlist that gets populated programmatically from a datasource. However, depending if the user is a admin user, I want to add 2 more list items to the Here is my code on how I add the list items programmatically to that list:
drpStatus.Items.Add("Admin") drpStatus.Items.Add("Global")
Problem with my code is, the value and display of the list item is the same. My value and display text differ. I need to have something like(excuse the code, but it does not render correctly when posted: How can I do this?You can use this one line code DropDownList1.Items.Add(new ListItem("test","t"));
Pankaj Gupta (Take it easy)