I have gridview and dynamic checkboxes in there, when user clicks one of the checkboxes, gridview's that row goes to edit mode and also filters data inside the dropdownlist and populates dropdownlist. I have created oncheckchanged() event handler that if
fires when someone clicks the checkbox, but when it is more than one checkbox clicks , after postback doesn't remember the previous values of the other checkbox. What I need to do? I am including commented ones so you can see what I even tried, didn't work.
pageload
If
Page.IsPostBack Then
'Dim grRow As GridViewRow
'For Each grRow In GridView1.Rows
' Dim ck1 As CheckBox = CType(grRow.FindControl("Chkerr"), CheckBox)
' Dim txtUniqueID As TextBox = CType(grRow.FindControl("txtUniqueID"), TextBox)
' ViewState(txtUniqueID.Text) = ck1.Checked.ToString()
'Next
Else
BindGrid(2424, "M", 1)
End If
'Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As EventArgs)
' Dim grRow As GridViewRow
' For Each grRow In GridView1.Rows
' Dim chkSelect As CheckBox = CType(grRow.FindControl("Chkerr"), CheckBox)
' Dim txtUniqueID As TextBox = CType(grRow.FindControl("txtUniqueID"), TextBox)
' If chkSelect.Checked = True Then
' Dim bChecked As Boolean = Boolean.Parse(ViewState(txtUniqueID.Text).ToString())
' chkSelect.Checked = bChecked
' End If
' Next
Sub Check_Clicked(ByVal sender
As Object,
ByVal e As EventArgs)
Dim ck1 As CheckBox =
CType(sender, CheckBox)
Dim row As GridViewRow =
CType(ck1.Parent.Parent, GridViewRow)
Dim currentrow
As Integer = row.RowIndex
' Display the primary key value of the selected row.
jaws1021
Member
50 Points
189 Posts
checkbox and viewstate
Jun 19, 2007 07:07 PM|LINK
I have gridview and dynamic checkboxes in there, when user clicks one of the checkboxes, gridview's that row goes to edit mode and also filters data inside the dropdownlist and populates dropdownlist. I have created oncheckchanged() event handler that if fires when someone clicks the checkbox, but when it is more than one checkbox clicks , after postback doesn't remember the previous values of the other checkbox. What I need to do? I am including commented ones so you can see what I even tried, didn't work.
pageloadIf
Page.IsPostBack Then 'Dim grRow As GridViewRow 'For Each grRow In GridView1.Rows ' Dim ck1 As CheckBox = CType(grRow.FindControl("Chkerr"), CheckBox) ' Dim txtUniqueID As TextBox = CType(grRow.FindControl("txtUniqueID"), TextBox) ' ViewState(txtUniqueID.Text) = ck1.Checked.ToString() 'Next Else BindGrid(2424, "M", 1) End If 'Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As EventArgs) ' Dim grRow As GridViewRow ' For Each grRow In GridView1.Rows ' Dim chkSelect As CheckBox = CType(grRow.FindControl("Chkerr"), CheckBox) ' Dim txtUniqueID As TextBox = CType(grRow.FindControl("txtUniqueID"), TextBox) ' If chkSelect.Checked = True Then ' Dim bChecked As Boolean = Boolean.Parse(ViewState(txtUniqueID.Text).ToString()) ' chkSelect.Checked = bChecked ' End If ' Next Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs) Dim ck1 As CheckBox = CType(sender, CheckBox) Dim row As GridViewRow = CType(ck1.Parent.Parent, GridViewRow) Dim currentrow As Integer = row.RowIndex ' Display the primary key value of the selected row.txtmessage.Text = GridView1.DataKeys(currentrow).Value.ToString()
If ck1.Checked = True Then If GridView1.DataKeys(currentrow).Value.ToString() <> 21 ThenGridView1.EditIndex = currentrow
BindGrid(2424, "M", 1) Else 'if it is 21 do that. End If 'if not checked Else 'if uncheck check box, get out edit mode.GridView1.EditIndex = -1
'even tried to gridview1.databind() instead calling bindgrid()
BindGrid(2424, "M", 1) End IfFill_DropDown()
End SubViewState asp.net View state Problem