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

  • Home
  • SEARCH
  • 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 123769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:20:20+00:00 2026-05-11T04:20:20+00:00

Can anyone tell the function to sort the columns of a gridview in c#

  • 0

Can anyone tell the function to sort the columns of a gridview in c# asp.net.

The gridview is databound to an oracle database. I wanted to click the header of the column to sort the data. i dont know how to refer to the header itself is it using the sender argument of the gridview_sorting 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. 2026-05-11T04:20:21+00:00Added an answer on May 11, 2026 at 4:20 am

    In the gridview control set the AllowSorting property to true

    <asp:GridView runat='server' ID='gvItems' AllowSorting='true' ...> 

    In the HeaderTemplate of the column you wish to sort set the SortExpression property to the field the tempate is bound to, if your not using a HeaderTemplate and using a BoundField there should also be a SortExpression property

    <asp:TemplateField SortExpression='ItemDescription' HeaderText='Item'>... 

    Implement the OnSorting method

    Inside of OnSorting use the second paramerter (GridViewSortEventArgs) to know what the sort expression is and rebind your gridview

    protected void gv_Sorting(object sender, GridViewSortEventArgs e) {      string fieldToSortOn = e.SortExpression;       //implement sort logic on datasource... } 

    That should get you a good start

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

Sidebar

Related Questions

Can anyone tell me why this works: $(#test1 td).click(function(event) { $(#test1).addClass(tableRowSelected); }); $(#test2 td).click(function(event)
Can anyone tell me what version of the .NET framework (CLR and BCL) is
can anyone tell me the function of following code. is the code line NSString*
Can anyone tell me that do scaleinto function will work on actual device having
Can anyone tell me how to insert a function call (say Yield() ) at
Can anyone tell me how to return multiple values from a function? Please elaborate
Can anyone tell me the detail explanation of the param parent in the function
Can anyone tell me why this isn't working? function changeBG(element_id){ document.getElementById(element_id).className= arrowActive; setTimeout(document.getElementById(+element_id+).className= 'arrow',
Can anyone tell me the use and application of select function in socket programming
Can anyone tell me what happened to the Html.Serialize function mentioned in the url

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.