?
Solved

make sorting datagrid faster

Posted on 2005-04-30
2
Medium Priority
?
287 Views
Last Modified: 2012-06-27
Hi,

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.

Thanks.


         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"
         Else
         SortMode = "Desc"
         End If
         Dim odataView as DataView = GenerateSource().DefaultView
         odataView.Sort=SortExpression
         datagrid1.DataSource=odataView
         datagrid1.DataBind()
         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",SqlDbType.int).Value = ddloperatorid.selecteditem.text
    cmd.Parameters.Add("@weekstartdate",SqlDbType.datetime).Value = ddlweek.selecteditem.text
    cmd.Parameters.Add("@qamonitorid",SqlDbType.int).Value = varqamonitorid
    Dim da As New SqlDataAdapter(cmd)
    Dim ds As New DataSet()
    da.Fill(ds,"DataSetName")
    Return ds.Tables("DataSetName")
    cmd.dispose
    cmd.parameters.clear
    con.close
    End function

0
Comment
Question by:EdwardPeter
2 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 2000 total points
ID: 13901321
That is about the best way you are going to do it.  What were you hoping to do faster?
0
 

Author Comment

by:EdwardPeter
ID: 13901332
raterus,

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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