Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

check boxes values saved in session across mutiple pages

$
0
0

I am working in as custom Webgrid built with infragistics. I am able to iterate thru the rows to get to the checkboxes and store the boxes that are check values into a session.

This is what is happen right now. On any page I click four checkboxes to change status to true. When I go to the next page and go back to previous page I have a method that repopulate the check boxes base on values and set those boxes to true. The method works

The problem is when on any page I click my boxes, go to the next page click on additional boxes, go back to the previous page the boxes are unchecked. Yet if I go to the next page my boxes are checked.

The desire help is to save the checkboxes checked values across multiple pages in to a session.

Public Sub Check_Clicked(sender As Object, e As EventArgs)
        Dim loadnumbers As String = ""
        Const comma As Char = (",")
        Try
            If Session("data") IsNot Nothing Then
                For Each row As UltraGridRow In iuwgLoadGrid.Rows
                    Dim myCellItem = GetGridCell(row, row.Index, "SELECTLOAD")
                    Dim myCheckBox = DirectCast(myCellItem.FindControl("chkSelectLoad"), CheckBox)
                    If (myCheckBox.Checked = True) Then
                        loadnumbers = loadnumbers & CType(GetGridCell(row, "lgh_number").Value, Integer) & comma
                        If Not Session("data").Contains(loadnumbers) Then
                            Session.Add("data", loadnumbers)
                        End If
                    ElseIf (myCheckBox.Checked = False) Then
                        loadnumbers = CType(GetGridCell(row, "lgh_number").Value, Integer) & comma
                        If Session("data").Contains(loadnumbers) Then
                            Session.Contents.Remove(loadnumbers)
                        End If
                    End If
                Next
            Else
                For Each row As UltraGridRow In iuwgLoadGrid.Rows
                    Dim myCellItem = GetGridCell(row, row.Index, "SELECTLOAD")
                    Dim myCheckBox = DirectCast(myCellItem.FindControl("chkSelectLoad"), CheckBox)
                    Dim data As String
                    If (myCheckBox.Checked = True) Then
                        loadnumbers = loadnumbers & CType(GetGridCell(row, "lgh_number").Value, Integer) & comma
                        Session("data") = loadnumbers
                    End If
                Next
            End If
        Catch ex As Exception
            Master.ShowMsg("", Message.Type.Error)
        End Try
    End Sub

Where is my mistake. also when I try tor remove the  a value from session.


Viewing all articles
Browse latest Browse all 23244

Trending Articles