Checkbox value added to session.
New DiscussionI have the following code looking I can retrieve the value of the check boxes. My problem is I getting all the values the one that are check and unchecked.
The String "lgh_number" is the DataKeyField
Public Sub Check_Clicked(sender As Object, e As EventArgs) Dim checkBox As CheckBox = DirectCast(sender, CheckBox) Dim data As New List(Of String)() Try For Each item As UltraGridRow In iuwgLoadGrid.Rows If checkBox IsNot Nothing Then If checkBox.Checked Then If Session("data") IsNot Nothing Then DirectCast(Session("data"), List(Of String)).Add(CType(GetGridCell(item, "lgh_number").Value, Integer)) End If Session("data") = data End If End If If checkBox.Checked Then If Session("data") IsNot Nothing Then DirectCast(Session("data"), List(Of String)).Remove(CType(GetGridCell(item, "lgh_number").Value, Integer)) End If Session("data") = data End If Next Catch ex As Exception End Try End Sub
Now I have change code to look like this.
Public Sub Check_Clicked(sender As Object, e As EventArgs) Dim tempCol As Infragistics.WebUI.UltraWebGrid.TemplatedColumn Dim checkBox As CheckBox Dim cObjs As ArrayList Dim data As New List(Of String)() Const comma As Char = (",") Dim cItems As Infragistics.WebUI.UltraWebGrid.CellItem Dim sChkName As String tempCol = iuwgLoadGrid.Rows(0).Cells(0).Column cObjs = tempCol.CellItems Try For Each item As Object In cObjs cItems = CType(item, Infragistics.WebUI.UltraWebGrid.CellItem) With cItems sChkName = "chkSelectLoad" & .Cell.Row.Cells.FromKey("SELECTLOAD").Value checkBox = .FindControl(sChkName) If checkBox IsNot Nothing Then If checkBox.Checked Then For Each row As UltraGridRow In iuwgLoadGrid.Rows DirectCast(Session("data"), List(Of String)).Add(CType(GetGridCell(row, "lgh_number").Value, Integer) & comma) Session("data") = data Next 'if this is checked then perform some function or store in an array or something. End If End If End With Next Catch ex As Exception End Try End Sub
This allow me to check if check is really check on the grid.
Yet when I try to add the value to session getting a object not reference error.
Ok here is the lastest changes it works, It find the check boxes that are check get the "lgh_number" the DataFieldKey. Stores it into a Session and checks for
duplicates. I have to reverse the process now to have the check boxes repopulate base on Page.
Public Sub Check_Clicked(sender As Object, e As EventArgs) Dim tempCol As Infragistics.WebUI.UltraWebGrid.TemplatedColumn Dim checkBox As CheckBox Dim cObjs As ArrayList Dim data As ArrayList Dim loadnumbers As String = "" Const comma As Char = (",") Dim cItems As Infragistics.WebUI.UltraWebGrid.CellItem Dim sChkName As String tempCol = iuwgLoadGrid.Rows(0).Cells(0).Column cObjs = tempCol.CellItems Try For Each item As Object In cObjs cItems = CType(item, Infragistics.WebUI.UltraWebGrid.CellItem) With cItems sChkName = "chkSelectLoad" & .Cell.Row.Cells.FromKey("SELECTLOAD").Value checkBox = .FindControl(sChkName) If checkBox IsNot Nothing Then If checkBox.Checked Then For Each row As UltraGridRow In iuwgLoadGrid.Rows If LoadDetailsLogic.GetCheckBoxControlValueFromGrid(row, "SELECTLOAD", "chkSelectLoad") Then loadnumbers = loadnumbers & CType(GetGridCell(row, "lgh_number").Value, Integer) & comma Session("data") = loadnumbers End If Next Dim val As String = Session("data") Dim arrVal As String() = val.Split(",") For Each s As String In arrVal If Not data.Contains(s) Then data.Add(s) End If Session("checkboxdata") = data Next Else For Each row As UltraGridRow In iuwgLoadGrid.Rows If LoadDetailsLogic.GetCheckBoxControlValueFromGrid(row, "SELECTLOAD", "chkSelectLoad") Then loadnumbers = loadnumbers & CType(GetGridCell(row, "lgh_number").Value, Integer) & comma End If Session.Contents.Remove(loadnumbers) Next End If End If End With Next Catch ex As Exception End Try End Sub
Sign In
to post a reply
Replies
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Favorites
0 Replies
2 Created On
Nov 07, 2013 Last Post
12 years, 10 months ago