Solved

Dropdwon list Simple Q

Posted on 2006-06-12
2
207 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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