Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am using a DataView to Sort my DataGrid.

 

I set the Datasource for the Datagrid to my DataView, then I bind my DataGrid. Works fine.

 

If user selects another option, I would like to RE-Sort my already sorted DataGrid.

 

In order to do this, I will need to obtain a DataTable to pass into the NEW DataView

 

I am using C#....

 


DataView view2 = new DataView(DataGrid1.DataTable????,"TheCity='"+city+"', PlusMinus DESC",DataViewRowState.CurrentRows);
[/Code]

 

Obviously there is no DataGrid1.DataTable Property. Is there a way to extract a DataTable?

Posted

Storing your datatable in viewstate may or may not be a good idea, it depends on the size of the datatable and the tolerable size of your resulting viewstate. But after you fill your datatable, you save it to your viewstate like..

 

ViewState("dtProducts") = myDatatable

 

Upon postback, you retrieve your datatable from your viewstate so you can do what you do with the dataview and rebind

 

Private Sub btnClick( s as object...)

Dim myDataTable As Datatable

 

myDataTable = ViewState("dtProducts")

 

End Sub

 

Viewstate is much like a Session variable but its scope is only at page level, typically it gets saved into a Viewstate hidden field in your page's html form, this is how it gets persisted between postbacks.

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...