RE: Datagrid sort

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: ETX (ETX_at_discussions.microsoft.com)
Date: 12/03/04


Date: Fri, 3 Dec 2004 05:39:06 -0800

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/issues/04/01/CuttingEdge/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.



Relevant Pages

  • Re: Datagrid sort
    ... > this way I do not need to launch the SQL query again. ... >>> My question is about the datagrid sorting. ... >>> columns but I don“t want to run the SQL query again. ...
    (microsoft.public.dotnet.general)
  • RE: Datagrid sort
    ... "ETX" wrote: ... > My question is about the datagrid sorting. ... > columns but I don“t want to run the SQL query again. ... > loosing the datatable every time the sorting function is launched. ...
    (microsoft.public.dotnet.general)
  • Re: Optimizing binding
    ... If you compare Sorting in sql query and in dataview, ... However when user clicks any column header in the datagrid, ... If you save the query result (dataview) in Session ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: ASP.NET Datagrid sorting
    ... I think for this type of sorting, you can do client side sorting. ... Other option is to have custom paging in your datagrid, ... > IntegerValue StringValue CurrencyValue ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Disable Sorting in VB.NET
    ... This problem sounds very strange since the DEFAULT of a DataGrid is NO ... the DataGrid's SortCommand event handler as well as define the sort criteria ... for each column of the DataGrid for sorting to work. ... > Private Sub datagrid_MouseDown(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)