Dropdown
-
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()
-
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()
Check that you are not calling the databind on ddlbatchid every time you post back to the page...
-
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()
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