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 3304262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:02:36+00:00 2026-05-17T21:02:36+00:00

I had Grid view and I added property allow sorting in it and I

  • 0

I had Grid view and I added property allow sorting in it and I converted all fields in grid view to item template and after that this error appeared (The GridView ‘GridView1’ fired event sorting which wasn’t handled)
Please anyone help me
.

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

‘>

  • 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-17T21:02:36+00:00Added an answer on May 17, 2026 at 9:02 pm

    If you are not binding your GridView to SqlDataSource and you are setting its AllowSorting to true, you need to do sorting manually. You need to assign sorting event to the GridView, and write your own code to implement the sorting. You can refer to the code below, and modify accordingly.

    On aspx page:

    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        onsorting="GridView1_Sorting">
    </asp:GridView>
    

    On codebehind:

    public partial class GridViewSort : System.Web.UI.Page
    {
        private const string ASCENDING = " ASC";
        private const string DESCENDING = " DESC";
    
        public SortDirection GridViewSortDirection
        {
            get
            {
                if (ViewState["sortDirection"] == null)
                    ViewState["sortDirection"] = SortDirection.Ascending;
    
                return (SortDirection)ViewState["sortDirection"];
            }
            set { ViewState["sortDirection"] = value; }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
                return;
    
            GridView1.DataSource = GetStaff();
            GridView1.DataBind();
        }
    
    
        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {
    
            string sortExpression = e.SortExpression;
    
            if (GridViewSortDirection == SortDirection.Ascending)
            {
                GridViewSortDirection = SortDirection.Descending;
                SortGridView(sortExpression, DESCENDING);
            }
            else
            {
                GridViewSortDirection = SortDirection.Ascending;
                SortGridView(sortExpression, ASCENDING);
            }   
        }
    
        private void SortGridView(string sortExpression, string direction)
        {
            DataTable dt = GetStaff();
    
            DataView dv = new DataView(dt);
            dv.Sort = sortExpression + direction;
    
            GridView1.DataSource = dv;
            GridView1.DataBind();
        }
    
        /// <summary>
        /// Dummy data
        /// </summary>
        /// <returns></returns>
        private DataTable GetStaff()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Age", typeof(int));
    
            for (int i = 1; i <= 20; i++)
            {
                dt.Rows.Add(i, "Staff - " + i, 20 );
            }
    
            return dt;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had grid view which bind sql data source and added field to update
In extjs3 Ext.grid.View had a config property forceFit . What is the equivalant to
I had grid view which retrieved data from database and mad update for specific
Consider a web page having grid-view connected to SqlDataSource having all permission to insert
I have a data grid in a view that is bound to a List
I have a SQLite database that is displayed in a data grid view in
I had these working great as navgrid settings like follows: this.Grid.navGrid('#' + this.PagerId, {},
in this sample the sorting of the grid works well with the first column.
I had a grid view populated from dataset and I have to redirect another
If I had a label on a view that I wanted to have the

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.