Avatar of Sukeshjph
Sukeshjph
 asked on

I want codes or links for implementing sortexpression in gridview...

I want codes for implementing sort expression in gridview...like i have a table with heading empid,vehicleinfo,photoid..when i click on the column header it will sort the gridview data according to that column data with ascending and descending order..
.NET Programming

Avatar of undefined
Last Comment
Sukeshjph

8/22/2022 - Mon
alexmiby

Sorry, fields in my example are different, but you can just replace the names... You don't really need the code, at least not if your task is as simple as you've described.
<asp:GridView ID="MembersGridView" runat="server" AllowPaging="True"
    AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="SerialNumber" DataSourceID="MembersSqlDataSource"
    GridLines="None" PageSize="30">
    <Columns>
        <asp:CommandField ButtonType="Button" ShowDeleteButton="True"
            ShowEditButton="True" />
        <asp:BoundField DataField="Username" HeaderText="Username"
            SortExpression="Username" />
        <asp:BoundField DataField="FirstName" HeaderText="First Name"
            SortExpression="FirstName" />
        <asp:BoundField DataField="Surname" HeaderText="Surname"
            SortExpression="Surname" />
    </Columns>
</asp:GridView>

Open in new window

Sukeshjph

ASKER
please dont use datakeynames and sqldatasource...as we are using layered arch..i want to know how to do it through dataview
ASKER CERTIFIED SOLUTION
alexmiby

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sukeshjph

ASKER
Thank you for the code
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck