I have a drop down list which is bound to a database field and is populated from so. However I want to add 1 of my own items to the drop down list no matter what is in the database. Is this possible?
ThanksYes. You can use the .Items.Add or .Items.Insert to add items to the dropdownlist. Just be sure to do this after you bind your data, because the bind will remove all items from the list.
hope this helps,
sivilian
Thanks very much, solved my problem.
Well the method is working but how we can set the additional item at the top, for example set "Select one State" on top of my drop down.
Thanks
Hello, try that in the page_load:
ddl.Items.Insert(new ListItem("text",value"),0);
regards
Thanks for you time,
Overload resolution failed because no accessible 'Insert' can be called with these arguments:
the aforsaid error return on line
AltShippingAdd.Items.Insert(new ListItem("Carbon", "C"),0);
Thanks in Advance
Hello,
this working fine, i think there is some problem in syntex.
AltShippingAdd.Items.Insert(0, New ListItem("Select One"))
the above statement is working fine but we can't able to define the value of that item is there a way to define the value of this item.
Thanks.
oh! in advance.
Hello, maybe you are right, I messed up with the syntax. but try to have:
AltShippingAdd.Items.Inert(0,new ListItem("Select One","1"))
regards
Thanks Bilal
It works fine
I am glad I was able to help you out my friend. For any further help, please dont hesitate to contact me here at the forums.
regards
0 comments:
Post a Comment