Home All Groups Group Topic Archive Search About
Author
20 Apr 2006 1:53 PM
Zamdrist
It's my understanding, in order to sort a datagrid you have to create a
new DataTable, correct?

So, if on the load of the page, you do something like this:

'adosDS & AdoConn are global in this instance
Dim adoSelect As New SqlCommand
Dim adoDa As New SqlDataAdapter

adoSelect.CommandType = CommandType.StoredProcedure
adoSelect.CommandText = "MG_SelectTMLSAssignments"
adoSelect.Connection = adoConn

adoDa.SelectCommand = adoSelect
adoDa.Fill(adoDS, "Assignments")
dgTMLSAssignments.DataSource = adoDS.Tables("Assignments").DefaultView
dgTMLSAssignments.DataBind()

You'd have to do the same thing essentially over again, in the
SortCommand event of the datagrid, correct?

The ASP.Net tutorial here:
http://www.asp.net/QuickStart/howto/doc/adoplus/FilterData.aspx says
you need only create a new dataview and set the Sort property, this
however doesn't work, generating the error: DataTable must be set prior
to using DataView

So...either I just don't get it, or Microsoft's example is incomplete
and/or erroneous.

Author
22 Apr 2006 12:16 AM
Peter Johnson
Yes in essence you do have to retrieve your data in some way again, if
it is a small amount of data you could store it in session or in
viewstate instead of going back to your database everytime the page
postsback.

The datatable needs to be populated everytime you wish to create a
dataview of the data within it.

Microsofts example is incomplete for that.

Try looking at this full tutorial for your issue
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

Regards,

Pete