Dear all .Netters,

I get problem with these controls, DropDownList, CheckBoxList, RadioButtonList.
Sometimes, i add item into those controls manually.
Example :
DropDownList1.Items.Add ("JAKARTA")
DropDownList1.Items.Add ("LONDON")
DropDownList1.Items.Add ("BOMBAY")
DropDownList1.Items.Add ("BEIJING")

If i use this property, DropDownList1.SelectedValue, it returns "JAKARTA",

If we bind it using DataReader, we find these properties DataTextField and DataValueField.
So, in DropDownList, the Item is Jakarta,London,Bombay,Beijing and the value is JKT,LDN,BOM,BEJ.
If i use this property, DropDownList1.SelectedValue, it returns "JKT".

My question is how to add value into DropDownList manually ?

Regards,

Kusno

Recommended Answers

All 2 Replies

Hope I understand your question right. You can manually add list items like this:

YourDropDownList.Items.Add(new ListItem("JAKARTA", "JKT"));

Thanks, It works.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.