We help IT Professionals succeed at work.
Get Started

Sorting a Gridview

632 Views
Last Modified: 2013-12-26
I am trying to make the column headers clickable for sorting purposes.  Code provided below.
<asp:GridView ID="dgResults" runat="server" AllowPaging="True" GridLines="None" AutoGenerateColumns="False" PageSize="25" CssClass="MemberDirectorySearchResultsTable" AllowSorting="True">
    <Columns>
        <asp:CommandField SelectText="" ShowSelectButton="True" HeaderText="Select" >
            <HeaderStyle CssClass="MemberDirectorySearchResultsColumnSelectHeader" />
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnSelect" />
        </asp:CommandField>
        <asp:BoundField >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnThumbnail" />
        </asp:BoundField>
        <asp:BoundField DataField="ID" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnID" />
            <HeaderStyle CssClass="MemberDirectorySearchResultsColumnIDHeader" />
        </asp:BoundField>
        <asp:BoundField DataField="FullName" HeaderText="Name/Title" HtmlEncode="False" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnName" />
        </asp:BoundField>
        <asp:BoundField DataField="MemberType" HeaderText="Member Type" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnMemberType" />
        </asp:BoundField>
        <asp:BoundField DataField="Company" HeaderText="Organization" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnOrganization" />
        </asp:BoundField>
        <asp:BoundField DataField="City" HeaderText="City" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnCity" />
        </asp:BoundField>
        <asp:BoundField DataField="State" HeaderText="State" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnState" />
        </asp:BoundField>
        <asp:BoundField DataField="ZipCode" HeaderText="Post" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnPostalCode" />
        </asp:BoundField>
        <asp:BoundField DataField="Country" HeaderText="Country" >
            <ItemStyle CssClass="MemberDirectorySearchResultsColumnCountry" />
        </asp:BoundField>
    </Columns>
    <RowStyle CssClass="MemberDirectorySearchResultsRow" />
    <HeaderStyle CssClass="MemberDirectorySearchResultsHeader" />
</asp:GridView>

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE