Solved

Dropdwon list Simple Q

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 81
C# Single Form 8 44
Counting connections to SQL Server through C# 3 34
I need help with Crystal Report's Parameter Prompt Form 2 17
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

825 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