D
David McCormick
I have been scouring the message boards before I posted this question hoping
to find an answer regarding datagrids and their behaviour after a sort
command has been invoked.
What I am trying to accomplish is this:
I have a datagrid that has several columns directly bound from data table
and on each row of the grid, the user has the ability to select that person
displayed. When the user does NOT sort this grid their selections are
correct after they submit their request, but as soon as they sort the grid
and select individuals, they receive the individuals in the position before
they sorted the grid. I am trying to ensure that the individual that is
being selected is really the individual that I am using moving forward.
Here is the code:
********* Grid Sorting *********
Public Sub grdResults_Sort(ByVal source As Object, ByVal e As
DataGridSortCommandEventArgs) Handles grdResults.SortCommand
Dim ds As New DataSet
ds = CType(Session("BorrowerList"), DataSet)
Dim dt As DataTable = ds.Tables(0)
Dim dv As DataView = New DataView(dt)
dv.Sort = e.SortExpression
grdResults.DataSource = dt
grdResults.DataBind()
End Sub
***** What I am doing to get the "selected items" out of the grid *****
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click
With grdResults
For Each DGItem In .Items
Dim checkBox As CheckBox =
CType(DGItem.Cells(0).Controls(1), CheckBox)
If checkBox.Checked = True Then
' Do something here
End If
Next
End With
End Sub
Any help would be great!
Thanks,
Dave
to find an answer regarding datagrids and their behaviour after a sort
command has been invoked.
What I am trying to accomplish is this:
I have a datagrid that has several columns directly bound from data table
and on each row of the grid, the user has the ability to select that person
displayed. When the user does NOT sort this grid their selections are
correct after they submit their request, but as soon as they sort the grid
and select individuals, they receive the individuals in the position before
they sorted the grid. I am trying to ensure that the individual that is
being selected is really the individual that I am using moving forward.
Here is the code:
********* Grid Sorting *********
Public Sub grdResults_Sort(ByVal source As Object, ByVal e As
DataGridSortCommandEventArgs) Handles grdResults.SortCommand
Dim ds As New DataSet
ds = CType(Session("BorrowerList"), DataSet)
Dim dt As DataTable = ds.Tables(0)
Dim dv As DataView = New DataView(dt)
dv.Sort = e.SortExpression
grdResults.DataSource = dt
grdResults.DataBind()
End Sub
***** What I am doing to get the "selected items" out of the grid *****
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click
With grdResults
For Each DGItem In .Items
Dim checkBox As CheckBox =
CType(DGItem.Cells(0).Controls(1), CheckBox)
If checkBox.Checked = True Then
' Do something here
End If
Next
End With
End Sub
Any help would be great!
Thanks,
Dave