Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

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.

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

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Problem solved, The tables name was not "myTable" but dtName instead.

 

Is it possible to search a dataset for a particular table, and if you find that table to remove it?

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...