Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add default value to databound dropdownlist

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi


I have a drop down list that is databound this way..

Code:
            MyConnection.Open()
            MyCommand = New SqlCommand("dbo.p_ShowProducts", MyConnection)
            MyCommand.CommandType = CommandType.StoredProcedure
            MyDataReader = MyCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
            DropDownListProducts.DataSource = MyDataReader
            DropDownListProducts.DataBind()


But I would like to add a default value like this...

Code:
DropDownListProducts.Items.Insert(0, "All products....")

But I don't know how to, is this possible at all?


Regards
 
DropDownListProducts.Items.Insert(0, new ListItem("All Products", "0"));

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top