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 ADD items

DropDown ADD items

Scheduled Pinned Locked Moved ASP.NET
databasecsharpsharepointsql-servervisual-studio
2 Posts 2 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.
  • M Offline
    M Offline
    Murugavel Sadagopan
    wrote on last edited by
    #1

    Hi, In Visual studio 2005, i have a drop down list. i want to add list of databases in dropdown list. i try the below mentioned code. But it returns System.Data.DataRowView in dropdown list not the database name. I also ensure in SQL Server execute the command "exec sp_databases" it returns 16 Databases names and autopostback property is also true. protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); using (SqlConnection sqlcon = new SqlConnection("Data Source=localhost;Initial Catalog=master;integrated security=true")) { sqlcon.Open(); string sQuery = "exec sp_databases"; SqlCommand cmd = new SqlCommand(sQuery, sqlcon); SqlDataAdapter objSqlDA = new SqlDataAdapter(cmd); objSqlDA.Fill(ds); DropDownList1.DataSource = ds; DropDownList1.DataBind(); } Thanks, Murugavel

    A 1 Reply Last reply
    0
    • M Murugavel Sadagopan

      Hi, In Visual studio 2005, i have a drop down list. i want to add list of databases in dropdown list. i try the below mentioned code. But it returns System.Data.DataRowView in dropdown list not the database name. I also ensure in SQL Server execute the command "exec sp_databases" it returns 16 Databases names and autopostback property is also true. protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); using (SqlConnection sqlcon = new SqlConnection("Data Source=localhost;Initial Catalog=master;integrated security=true")) { sqlcon.Open(); string sQuery = "exec sp_databases"; SqlCommand cmd = new SqlCommand(sQuery, sqlcon); SqlDataAdapter objSqlDA = new SqlDataAdapter(cmd); objSqlDA.Fill(ds); DropDownList1.DataSource = ds; DropDownList1.DataBind(); } Thanks, Murugavel

      A Offline
      A Offline
      Aavesh Agarwal
      wrote on last edited by
      #2

      hi U didn't bind the DataTextField and DataValueField of the Dropdownlist. Bind the DataTextField with Database Name and DatavalueField with DatabaseID. Hope this will help u Regards Avesh Agarwal

      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