views:

29

answers:

1

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?

+2  A: 

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.

drachenstern
@drach Thanks! I am not sure when I set those for the columns I did not want to sort by, but I would not have thought to check there. I appreciate the help. Have a great day!
PFranchise
@PFranchise, you're more than welcome mate. Enjoy the afternoon ;)
drachenstern