Here is my situation, I have a DropDownList in a repeater. The DDL is databound and will display a list of choices to select from. However, I would like to add a 'Select....' item to the DDL. I tried sticking a ListItem in the DDL definition, but that didn't
work. I also used code in my repeaters onItemCreated method that programmatically added the item, but it seems that when the items databind() method fires, it clears the dropdownlist and it only includes the elements in the database. Any suggestions?
From another post earlier, which seems to have the same issue: If you add it before you bind, the binding will over-write it. If you add it after you bind, the "Make Selection" will be at the end of the list. Here is a snip that will put it at the top: [code]
DropDownList1.DataSource = dataSource; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, "Make Selection"); [/code] Hope this helps. Charley.
yonah
Member
590 Points
118 Posts
Adding a single Entry to a data bound DropDownList
Aug 06, 2003 01:58 PM|LINK
Charley Bogw...
Participant
1880 Points
374 Posts
Re: Adding a single Entry to a data bound DropDownList
Aug 06, 2003 06:37 PM|LINK