Solved

Dropdwon list Simple Q

Posted on 2006-06-12
2
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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