Solved

Dropdwon list Simple Q

Posted on 2006-06-12
2
204 Views
Last Modified: 2010-04-16
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
Comment
Question by:claracruz
2 Comments
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 16885928
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
 
LVL 4

Author Comment

by:claracruz
ID: 16886486
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now