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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. cascaded dropdown list box.

cascaded dropdown list box.

Scheduled Pinned Locked Moved Web Development
help
3 Posts 2 Posters 1 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.
  • K Offline
    K Offline
    Kunal P
    wrote on last edited by
    #1

    cascaded dropdown listbox hi. i am developing a web based application in Visual WeB Developer EXPRESS. I have a Drop down list that which is statically filled. Now i wanted that wen i select a particular field from the Drop Down List, a table of the same name shud be accessed, and a particular column be filled in the Listbox Control. i wrote a piece of code try { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "Select * from [" + DropDownList1.SelectedValue + "]";+ "'"; SqlDataReader dread = cmd.ExecuteReader(); dread.Read(); while (dread.Read()) { ListBox1.Items.Add(dread["column_name"].ToString()); } conn.Close(); the problem is that no row is being retrieved.. please help..

    Kunal Piyush

    C 1 Reply Last reply
    0
    • K Kunal P

      cascaded dropdown listbox hi. i am developing a web based application in Visual WeB Developer EXPRESS. I have a Drop down list that which is statically filled. Now i wanted that wen i select a particular field from the Drop Down List, a table of the same name shud be accessed, and a particular column be filled in the Listbox Control. i wrote a piece of code try { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "Select * from [" + DropDownList1.SelectedValue + "]";+ "'"; SqlDataReader dread = cmd.ExecuteReader(); dread.Read(); while (dread.Read()) { ListBox1.Items.Add(dread["column_name"].ToString()); } conn.Close(); the problem is that no row is being retrieved.. please help..

      Kunal Piyush

      C Offline
      C Offline
      Chris Buckett
      wrote on last edited by
      #2

      cmd.CommandText = "Select * from [" + DropDownList1.SelectedValue + "]";

      • "'";

      If you've just copied and pasted, then you have 2 statements on the one line. the final +"'"; is a separate statement from the cmd.CommandText .... "]"; statement Have you tried running your code by entering in a complete dummy sql string just to check it works rather than using the dropdownlist.selectedvalue?

      ChrisB ChrisDoesDev[^]

      K 1 Reply Last reply
      0
      • C Chris Buckett

        cmd.CommandText = "Select * from [" + DropDownList1.SelectedValue + "]";

        • "'";

        If you've just copied and pasted, then you have 2 statements on the one line. the final +"'"; is a separate statement from the cmd.CommandText .... "]"; statement Have you tried running your code by entering in a complete dummy sql string just to check it works rather than using the dropdownlist.selectedvalue?

        ChrisB ChrisDoesDev[^]

        K Offline
        K Offline
        Kunal P
        wrote on last edited by
        #3

        this is how it is.. it was probably due to modification.. that there was an other statement. cmd.CommandText = "Select * from [" + DropDownList1.SelectedValue + "]"; i checked with a dummy string.. no retrieval. also wen i had a string like this cmd.CommandText = "Select * from '" + DropDownList1.SelectedValue + "'"; it showed an error.. Incorrect syntax near [valuename]

        Kunal Piyush

        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