Home
Manage Your Code
Snippet: Add first item to dropdownlist (C#)
Title: Add first item to dropdownlist Language: C#
Description: Add first item to dropdownlist Views: 555
Author: leno smith Date Added: 1/18/2008
Copy Code  
1//using if(ddl2.SelectedIndex==0) which is the first item called "please select a item" to prompt user that he cant select this value

2    private void BindDDL2()
3    {
4        DataSet ds = Videos.GetVidInfoByUserName("jim");
5        Videos.CloseConn();
6        //ds.Tables[0].Rows[0]["imagefilename"] = "Please select a image filename";

7        ddl2.DataSource = ds;
8        ddl2.DataTextField = "imagefilename";
9        ddl2.DataValueField = "id";
10        ddl2.DataBind();
11       
12    }
Usage
//