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

Dropdown

Scheduled Pinned Locked Moved ASP.NET
databasesysadminhelpquestion
3 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.
  • D Offline
    D Offline
    david boon
    wrote on last edited by
    #1

    hi, i have a drop down list where i bind data from database. on selected index changed iam displaying a datagrid. everthing works fine but when click dropdown eachtime i find that same data is adding on to the dropdownlist. what to do? plz help meout. code is: Private Sub ddlbatchid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlbatchid.SelectedIndexChanged str9 = Me.ddlbatchid.SelectedValue conn.ConnectionString = "server=127.userid=root;password=proagnes;database=erpl" conn.Open() cmd.CommandText = "SELECT * FROM courses WHERE batchid='" & str9 & "'" cmd.Connection = conn da.SelectCommand = cmd da.Fill(ds, "courses") Dim dtCourses As DataTable = ds.Tables("courses") Repeater1.DataSource = dtCourses Repeater1.DataBind() btnsubmit.Visible = True conn.Close()

    P D 2 Replies Last reply
    0
    • D david boon

      hi, i have a drop down list where i bind data from database. on selected index changed iam displaying a datagrid. everthing works fine but when click dropdown eachtime i find that same data is adding on to the dropdownlist. what to do? plz help meout. code is: Private Sub ddlbatchid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlbatchid.SelectedIndexChanged str9 = Me.ddlbatchid.SelectedValue conn.ConnectionString = "server=127.userid=root;password=proagnes;database=erpl" conn.Open() cmd.CommandText = "SELECT * FROM courses WHERE batchid='" & str9 & "'" cmd.Connection = conn da.SelectCommand = cmd da.Fill(ds, "courses") Dim dtCourses As DataTable = ds.Tables("courses") Repeater1.DataSource = dtCourses Repeater1.DataBind() btnsubmit.Visible = True conn.Close()

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      Check that you are not calling the databind on ddlbatchid every time you post back to the page...

      1 Reply Last reply
      0
      • D david boon

        hi, i have a drop down list where i bind data from database. on selected index changed iam displaying a datagrid. everthing works fine but when click dropdown eachtime i find that same data is adding on to the dropdownlist. what to do? plz help meout. code is: Private Sub ddlbatchid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlbatchid.SelectedIndexChanged str9 = Me.ddlbatchid.SelectedValue conn.ConnectionString = "server=127.userid=root;password=proagnes;database=erpl" conn.Open() cmd.CommandText = "SELECT * FROM courses WHERE batchid='" & str9 & "'" cmd.Connection = conn da.SelectCommand = cmd da.Fill(ds, "courses") Dim dtCourses As DataTable = ds.Tables("courses") Repeater1.DataSource = dtCourses Repeater1.DataBind() btnsubmit.Visible = True conn.Close()

        D Offline
        D Offline
        Daniel Santillanes
        wrote on last edited by
        #3

        It seems to me that you manually add the data to the dropdown, and not doing it through a databind, and it seems this code is being called on every post back. If it's on the Page's load event, you don't need to bind the data to the dropdown everytime if you have viewstate enabled for your dropdown. Hope this helps. daniero

        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