Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting GridView
Message
From
28/06/2010 09:41:40
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Sorting GridView
Miscellaneous
Thread ID:
01470784
Message ID:
01470784
Views:
87
I am following the example in the MM.NET help file to allow sorting in a gridview. This is the code that is given:
        protected void grdList_Sort(object sender, GridViewSortEventArgs e)
        {
            // Get the sort direction from the event args
            string SortOrder = e.SortDirection == SortDirection.Ascending ? "ASC" : "DESC";

            // Get the SortExpression from the event args and use it along with the sort order to
            // set the DefaultView's Sort property
            DataTable dtClients = (DataTable)Session["dtClients"];
            dtClients.DefaultView.Sort = e.SortExpression + " " + SortOrder;

            // Save the DataTable back to the session, then rebind the GridView
            Session["dtClients"] = dtClients;
            this.grdList.DataSource = dtClients.DefaultView;
            this.grdList.DataBind();

        }
I am getting an error:

"'string' does not contain a definition for 'Ascending' and no extension method 'Ascending' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)"

this is on the "SortDirection.Ascending".

Where does SortDirection come from?

< UPDATE >

I found a SortDirection declared in my code that was leftover from some other old code! Hope I didn't waste anyone's time.

Although I think I have another question as my grid is now not showing the data :(
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Reply
Map
View

Click here to load this message in the networking platform