cuzziman84
New Member
Hi all,<BR><BR>After I bind some data to a dropdownlist, how can I add an option to the beginning of the list? Example:<BR><BR>--Choose an option--- (<-- add this option)<BR>BoundData 1<BR>BoundData 2<BR>etc.<BR><BR>Thanks,<BR>D.hi,<BR><BR>After binding u have to add like this<BR><BR>Let us say "cborole" is dropdown list name<BR>add this line after bibding<BR><BR>"cboRole.Items.Insert(0, New ListItem("Select a Name", 0))"<BR><BR>you can refer the below sample coding also:-<BR>--------------------------------------------<BR>Dim MyConnection As New SqlConnection("server=(local)NetSDK;database=pubs;Trusted_Connect ion=yes")<BR> Dim sqlcommand As New SqlDataAdapter("select * from authors", MyConnection)<BR> Dim ds As New DataSet()<BR> sqlcommand.Fill(ds)<BR> cboRole.DataSource = ds.Tables(0).DefaultView<BR> cboRole.DataTextField = "au_lname"<BR> cboRole.DataValueField = "au_id"<BR> cboRole.DataBind()<BR> cboRole.Items.Insert(0, New ListItem("Select a Name", 0))<BR>------------------------------------------------------------<BR><BR>hope this will help u<BR>regards<BR>yesu