• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Dropdwon list Simple Q

Hello experts,

I am doing the following to populate a dropdown list.

<asp:DropDownList ID="make" Runat="server" DataSourceID="ObjectDataSource2" DataTextField="make" DataValueField="make" CssClass="input"/>
<asp:ObjectDataSource ID="ObjectDataSource2" Runat="server" TypeName="AuctionsDB" SelectMethod="GetVehiclesByMake"/>

I also need an option in the list that states ---Any---, how do I achieve this if I am binding the control to a datasource..


Many Thanks

Clara
0
claracruz
Asked:
claracruz
1 Solution
 
dstanley9Commented:
Easiest way is to add it to the datasource before data binding occurs.

Alternate way is to manually asdd the item after databinding:

http://support.microsoft.com/?kbid=314334

Another way (if using .NET 2.0) is to add an event handler to the DataBound event to add the item:

protected void make_DataBound(object sender, EventArgs e) {
    make.Items.Insert(0, new ListItem("---Any---", "-1"));
}
0
 
claracruzAuthor Commented:
thanks
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now