make sorting datagrid faster

Posted on 2005-04-30
Last Modified: 2012-06-27

Is there anothery of sorting a datagrid column for faster results? if so please kindly give guidance.

Presently the sorting is taking so long since it would need to requrey fro mthe sql server.


         Sub Sort_Grid(sender As Object, e As DataGridSortCommandEventArgs)
         Dim SortExpression As String
         SortExpression = e.SortExpression.ToString()
         If SortMode = "Desc" Then
         SortMode = "Asc"
         SortExpression = SortExpression + " " + "Desc"
         SortMode = "Desc"
         End If
         Dim odataView as DataView = GenerateSource().DefaultView
         End Sub 'Sort_Grid

    Private Function GenerateSource() As DataTable
    Dim con As New SqlConnection("Server=.....")
    Dim cmd As SqlCommand = con.CreateCommand()
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = "SP_operator_score_details_view"
    cmd.Parameters.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", DataRowVersion.Current, Nothing))
    cmd.Parameters.Add("@operatorid", = ddloperatorid.selecteditem.text
    cmd.Parameters.Add("@weekstartdate",SqlDbType.datetime).Value = ddlweek.selecteditem.text
    cmd.Parameters.Add("@qamonitorid", = varqamonitorid
    Dim da As New SqlDataAdapter(cmd)
    Dim ds As New DataSet()
    Return ds.Tables("DataSetName")
    End function

Question by:EdwardPeter
    LVL 33

    Accepted Solution

    That is about the best way you are going to do it.  What were you hoping to do faster?

    Author Comment


    if that's the case then question is answered :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now