Hi
I recently downloaded a checkbox component for the datagrid from http://www.metabuilders.com/. The component allows you to place a row of checkboxes in a datagrid from which the user can then select as many as they wish/ or none at all.
A problem arises when you introduce paging to the datagrid, i.e. if i select 3 of the checkboxes on page 1 of my datagrid and then move to page 2, my selections are automatically deleted.
Therefore I have created a Session variable that stores a dataset. I have created a datatable, myTable that has 2 columns "Member_ID" and "Value". I run through my datagrid just before I do the paging and select all checked rows into the table (that works).
The problem arises when I try to add the new datatable to the existing dataset and then bind that dataset to another datagrid.
Would appreciate any suggestions??
This section gets cell(1) of the rows that have been checked and inserts the number into the datatable.
This code should get the dataset from the session ds, update the dataset and return the data to the session, and finally bind to the datagrid.
Mike55
I recently downloaded a checkbox component for the datagrid from http://www.metabuilders.com/. The component allows you to place a row of checkboxes in a datagrid from which the user can then select as many as they wish/ or none at all.
A problem arises when you introduce paging to the datagrid, i.e. if i select 3 of the checkboxes on page 1 of my datagrid and then move to page 2, my selections are automatically deleted.
Therefore I have created a Session variable that stores a dataset. I have created a datatable, myTable that has 2 columns "Member_ID" and "Value". I run through my datagrid just before I do the paging and select all checked rows into the table (that works).
The problem arises when I try to add the new datatable to the existing dataset and then bind that dataset to another datagrid.
Would appreciate any suggestions??
This section gets cell(1) of the rows that have been checked and inserts the number into the datatable.
Code:
Dim rsc As MetaBuilders.WebControls.RowSelectorColumn = MetaBuilders.WebControls.RowSelectorColumn.FindColumn(dgMembers)
Dim selected As Integer
Dim selIndex As Integer
Dim result As Boolean
Dim myTable As New DataTable(dtName)
Dim myMember As New DataColumn("Member_ID")
Dim myValue As New DataColumn("Value")
myMember.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(myMember)
myValue.DataType = System.Type.GetType("System.Boolean")
myTable.Columns.Add(myValue)
selected = 0
For Each selIndex In rsc.SelectedIndexes
selected = selected + 1
Dim row As DataRow
row = myTable.NewRow()
row.Item("Member_ID") = dgMembers.Items(selIndex).Cells(1).Text
row.Item("Value") = "True"
myTable.Rows.Add(row)
Next
This code should get the dataset from the session ds, update the dataset and return the data to the session, and finally bind to the datagrid.
Code:
dsDataset = Nothing
dsDataset = CType(Session("ds"), DataSet)
dsDataset.Tables.Add(myTable)
Session("ds") = ""
Session("ds") = dsDataset
DataGrid1.DataSource = CType(Session("ds"), DataSet).Tables("myTable")
DataGrid1.DataBind()
Mike55