tags:

views:

23

answers:

2

I have a dropdown list that is currently populated from a result set of a stored procedure. The datasource for the DDL is set to the resultset.

Without inserting a default record into the database (I don't want to do this) how can I add an item to the DDL which is the default selected item on form load?

+2  A: 

Modify the stored procedure to include and union a dummy row.

(SELECT 1 as X, 'abc' AS Y) UNION (SELECT X, Y FROM your_table);
mikerobi
This worked great, thanks.
A: 

The other option is adding the "default" selection to the datasource before binding it to the combobox.

Something like this would be for a DataTable

DataRow row = dt.NewRow();
row["Id"] = 0;
row["Text"] = "Select...";

dt.Rows.InsertAt(row, 0);
Claudio Redi