Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dropdown first Item

Dropdown first Item

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadminquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nour123
    wrote on last edited by
    #1

    I have a form that deletes users, I use a a dropdown to select the user I want to delete(using SQL Server Database), I want the first element to be "Please select one of the following" How could it be? Regards

    G 1 Reply Last reply
    0
    • N nour123

      I have a form that deletes users, I use a a dropdown to select the user I want to delete(using SQL Server Database), I want the first element to be "Please select one of the following" How could it be? Regards

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Add the item to the data source before populating the list, or use the Insert method of the list to insert an item after you have populated it.

      --- Year happy = new Year(2007);

      N 1 Reply Last reply
      0
      • G Guffa

        Add the item to the data source before populating the list, or use the Insert method of the list to insert an item after you have populated it.

        --- Year happy = new Year(2007);

        N Offline
        N Offline
        nour123
        wrote on last edited by
        #3

        Hi Dear Thanks alot for your reply give me a ststement how to use the insert method in my case, here i send you the code if needed: If Not IsPostBack Then conn1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Hosting;Data Source=JICC" conn1.Open() Dim cm1 As New OleDbCommand("select * from Types", conn1) Dim ds1 As New DataSet Dim da1 As New OleDbDataAdapter Dim dr1 As OleDb.OleDbDataReader dr1 = cm1.ExecuteReader() If dr1.HasRows = False Then Label1.Text = "No records..." Label1.Visible = True DropDownList1.Enabled = False Button1.Enabled = False Else Dim cmd1 As New OleDbCommand("select * from Types order by t_name", conn1) da1.SelectCommand = cmd1 da1.Fill(ds1, "types") DropDownList1.DataTextField = "t_name" DropDownList1.DataValueField = "t_id" DropDownList1.DataSource = ds1.Tables(0).DefaultView DropDownList1.DataBind() da1.Dispose() End If End If

        P 1 Reply Last reply
        0
        • N nour123

          Hi Dear Thanks alot for your reply give me a ststement how to use the insert method in my case, here i send you the code if needed: If Not IsPostBack Then conn1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Hosting;Data Source=JICC" conn1.Open() Dim cm1 As New OleDbCommand("select * from Types", conn1) Dim ds1 As New DataSet Dim da1 As New OleDbDataAdapter Dim dr1 As OleDb.OleDbDataReader dr1 = cm1.ExecuteReader() If dr1.HasRows = False Then Label1.Text = "No records..." Label1.Visible = True DropDownList1.Enabled = False Button1.Enabled = False Else Dim cmd1 As New OleDbCommand("select * from Types order by t_name", conn1) da1.SelectCommand = cmd1 da1.Fill(ds1, "types") DropDownList1.DataTextField = "t_name" DropDownList1.DataValueField = "t_id" DropDownList1.DataSource = ds1.Tables(0).DefaultView DropDownList1.DataBind() da1.Dispose() End If End If

          P Offline
          P Offline
          payback
          wrote on last edited by
          #4

          ddlTitle.Items.Insert(0, New ListItem("Choose Title", "0")) put this after finishing data binding.

          N 1 Reply Last reply
          0
          • P payback

            ddlTitle.Items.Insert(0, New ListItem("Choose Title", "0")) put this after finishing data binding.

            N Offline
            N Offline
            nour123
            wrote on last edited by
            #5

            thanks alot dear it works have a nice day regards... Nour Abdel-Salam

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups