Adding dropdown option after bind

Results 1 to 2 of 2

Thread: Adding dropdown option after bind

  1. #1
    Join Date
    Dec 1969

    Default Adding dropdown option after bind

    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--- (&#060;-- add this option)<BR>BoundData 1<BR>BoundData 2<BR>etc.<BR><BR>Thanks,<BR>D.

  2. #2
    Join Date
    Dec 1969

    Default RE: Adding dropdown option after bind

    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_Connection=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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts