Is the DataTable you use going to contain the same data for all of your
users? If so, then your solution is fine. If it should be different for
each user, then you may have a problem. What is stored in the cache is
accessible at a site-wide level, rather than at the request level.
Other alternatives for storage locations are:
Session
ViewState
Often, if the DataTable is relatively small in size and I need to provide
sorting capabilities, I place it in the ViewState to avoid doing another hit
to the database. Only drawback to this is that the larger the DataTable,
the more data must be sent down to the client for the ViewState.
--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"ETX" <ET*@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Thanks Rakesh.
I found other way to keep the datatable stored.
I have cached the resulting datatable and then retrieved it from cache,
this way I do not need to launch the SQL query again. the code was
someting
like this:
SQLResults = SQLQuery.execute
'Cahe the resulting datatable.
Cache("DataTableCached") = SQLResults
BindGrid()
Sub BindGrid()
'Retrieve Datasource from Cache
Dim source As DataTable
source = Cache("DataTableCached")
'return a DataView to the DataTable
Dim dv As DataView = New DataView(source)
If SortField Is Nothing Then
SortField = "Title"
End If
dv.Sort = SortField
dg_Results.DataSource = dv
dg_Results.DataBind()
End Sub
"Rakesh Rajan" wrote:
Hi ETX,
Check out these articles which discuss the same:
http://msdn.microsoft.com/msdnmag/is...e/default.aspx
http://www.eggheadcafe.com/articles/20021022b.asp
HTH,
Rakesh Rajan
"ETX" wrote:
> Hello,
> My question is about the datagrid sorting. I have a datatable that is
> filled
> up with the data retrieved from an SQL query.I use that datatable as
> source
> for my datagrid. I would like to make the datagrid sortable by each of
> the
> columns but I don´t want to run the SQL query again. The problem is
> that I'm
> loosing the datatable every time the sorting function is launched. I'm
> not
> allowed to use session variables and I don't know how to store the
> datatable
> in order that I don't loose it when the sorting is launched.
> I would be very gratefull if you could post an example of how can I
> solve
> this issue.
> Thnaks a lot.