PFranchise
PFranchise

Reputation: 6752

easiest way to make only one column sortable

I have a datagrid with sorting. I set enable sorting to true, but that makes every column sortable. Is there a simple way to make it so that only one column header can be clicked for sorting? I feel like there should be a simple and quick fix for this, but who knows.

some code:

        <asp:GridView ID="ProductsGrid" runat="server" 
        AutoGenerateColumns="False" Height="323px"
        style="margin-top: 23px; margin-left: 0px;" BackColor="White" CellPadding="0"
        Width="1210px" OnPageIndexChanging="gridView_PageIndexChanging"
        onrowdatabound="ProductsGridView_RowDataBound" AllowPaging="True"
        PageSize="25" AllowSorting="True" OnSorting="ProductsGrid_SortCommand">

I then have several columns. Is there something I can set in the code for the column to disable all others or only make one sortable?

Upvotes: 2

Views: 1642

Answers (1)

jcolebrand
jcolebrand

Reputation: 16025

http://msdn.microsoft.com/en-us/library/aa479347.aspx

You can specify if a column should be sortable or not by its SortExpression property.

Hope this helps.

Upvotes: 3

Related Questions