Reputation: 1
I want to add 'All' option on top of other records fetched from database shown in dropdownlist.Any ideas on how to do this in vb.net 2005?
Upvotes: 0
Views: 1350
Reputation: 1
below worked for me!
Add a new row to datasource
Dim dr As DataRow = ds.Tables("cusPracticeLocation").NewRow
'Add some data to it
dr(0) = 0
dr(1) = "All"
ds.Tables("cusPracticeLocation").Rows.InsertAt(dr, 0)
Upvotes: 0
Reputation: 2660
Think around the problem. Instead of adding the item to the combobox, add the item to the dynamic datasource.
Upvotes: 1
Reputation: 460098
Even in VS 2005 the AppendDataBoundItems
property was available. So you can add this item programmatically from codebehind or declaratively on aspx:
<asp:DropDownList
runat="server"
ID="DropDownList1"
AppendDataBoundItems="true"
>
<asp:ListItem
Enabled="True"
Selected="True"
Text="All"
Value="0"
/>
</asp:DropDownList>
Now all your databound items are appended automatically and the first item will not be removed.
Upvotes: 0