Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3947604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:16:18+00:00 2026-05-20T01:16:18+00:00

I have an ASP DataGrid and I’m applying sorting to it. Well, as I

  • 0

I have an ASP DataGrid and I’m applying sorting to it. Well, as I was looking at an example, they had a function similar in function, different in name, to:

Private Sub dgTasks_SortGrid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles dgTasks.SortCommand
    Dim strSortDirection As String = Session("SortDir")
    If strSortDirection = Nothing Then
        strSortDirection = " ASC "
    Else
        If strSortDirection = " ASC " Then
            strSortDirection = " DESC "
        Else
            strSortDirection = " ASC "
        End If
    End If
    Session("SortDir") = strSortDirection
    BindData(e.SortExpression & strSortDirection)
End Sub

Well, me trying to make shortcuts and make things “easier” thought maybe this would be best:

Private Sub dgTasks_SortGrid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles dgTasks.SortCommand
    If Session("SortDir") = Nothing Then
        Session("SortDir") = " ASC "
    Else
        If Session("SortDir") = " ASC " Then
            Session("SortDir") = " DESC "
        Else
            Session("SortDir") = " ASC "
        End If
    End If
    BindData(e.SortExpression & Session("SortDir"))
End Sub

However, as I was thinking about it, I figured maybe Session("SortDir") has to make a request everytime and it could have some affect or drawbacks. But I wasn’t sure. Does anyone have any links that would explain the best or preferred method. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:16:19+00:00Added an answer on May 20, 2026 at 1:16 am

    Looking up the Session value twice (one read and one write) rather than four times seems clearly better. The performance difference won’t be noticable by the user, but all those redundant lookups would make most programmers very uncomfortable! And there are some occasions where this kind of thing could make a noticable difference, depeding on the amount of data stored in the collection, and the type of lookup performed (hash table, binary search, sequential search, etc.), so it’s probably not a good habit to get into.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a asp.net application.there is a databinding section to a datagrid.But there have
I am new ASP.NET and I have never used a GridView or DataGrid, but
I have a asp:DataGrid which holds data in two columns on my webpage. The
I have created an event handler for the OnSortCommand of DataGrid: <asp:DataGrid id=dtgBatches runat=server
I am dynamically creating dragrids in different rows of an existing datagrid in asp.NET
I am using asp.net 2.0 and c#. I have a datagrid in which I
I have the following datagrid: <asp:DataGrid runat=server ID=gastosReembolsables ShowFooter=True AutoGenerateColumns=False> <AlternatingItemStyle CssClass=DATAitem2></AlternatingItemStyle> <ItemStyle CssClass=DATAitem1></ItemStyle>
Hi i have a datagrid with <asp:BoundField DataField=PrenotazioneEffettuata HeaderText=Pren. Effettuate SortExpression=PrenotazioneEffettuata /> PrenotazioneEffettuata is
I have dataGrid and LinkButton with javascript, how to get ID for MessageSend function?
I have an ASP.NET Datagrid with several text boxes and drop down boxes inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.