I will created dynamic check boxes in panel but it losing the checked values when i reloads
-
I will created dynamic check boxes in panel but it losing the checked values when i reloads Example : no problem with bind data but when i click submit i need to reload the binddata() definitely other wise panel doesn't show any items. if i reload then checked values are losing when i calling the submit button. sub binddata() dim ds as dataset // here i will take data source from which from database. Try ds=obj.GetSource() For index = 0 To ds.Tables(0).Rows.Count - 1 chklist = New CheckBox chklist.Text = ds.Tables(0).Rows(index).Item(0).ToString chklist.ID = ds.Tables(0).Rows(index).Item(0).ToString chklist.EnableViewState = True Panel1.Controls.Add(chklist) Panel1.Controls.Add(New LiteralControl(" ")) Next end sub problem below when i reloads the databind(). but i need to be definitely reloads the databind other wist panel doen't show any thing Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click While index < ds.Tables(0).Rows.Count DisplayPanel = CType(FindControl("panel1"), Panel) chklist1 = CType(DisplayPanel.FindControl(ds.Tables(0).Rows(index).Item(0).ToString), CheckBox) If Not chklist1 Is Nothing Then chklist1.Text = ds.Tables(0).Rows(index).Item(0).ToString If chklist1.Checked = True Then //here showing that not checking even thought i will check check boxes objWeb.Addid(drlist.SelectedItem.Value, chklist1.ID) End If End If index = index + 1 End While end sub this is haneef
this is haneef
-
I will created dynamic check boxes in panel but it losing the checked values when i reloads Example : no problem with bind data but when i click submit i need to reload the binddata() definitely other wise panel doesn't show any items. if i reload then checked values are losing when i calling the submit button. sub binddata() dim ds as dataset // here i will take data source from which from database. Try ds=obj.GetSource() For index = 0 To ds.Tables(0).Rows.Count - 1 chklist = New CheckBox chklist.Text = ds.Tables(0).Rows(index).Item(0).ToString chklist.ID = ds.Tables(0).Rows(index).Item(0).ToString chklist.EnableViewState = True Panel1.Controls.Add(chklist) Panel1.Controls.Add(New LiteralControl(" ")) Next end sub problem below when i reloads the databind(). but i need to be definitely reloads the databind other wist panel doen't show any thing Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click While index < ds.Tables(0).Rows.Count DisplayPanel = CType(FindControl("panel1"), Panel) chklist1 = CType(DisplayPanel.FindControl(ds.Tables(0).Rows(index).Item(0).ToString), CheckBox) If Not chklist1 Is Nothing Then chklist1.Text = ds.Tables(0).Rows(index).Item(0).ToString If chklist1.Checked = True Then //here showing that not checking even thought i will check check boxes objWeb.Addid(drlist.SelectedItem.Value, chklist1.ID) End If End If index = index + 1 End While end sub this is haneef
this is haneef
Hi Hafneef, Are you saving values of check box i.e in database or XML file . You need to save check box values and when you reload them dynamically then you need to put those values into check boxes. Tip: Check if you are missing "Ispostback"
Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam