Datagridview reordering

hi - I'm working with a datagridview control. I would like to disable the feature that allows the user to click on the header bar and the respective column is reordered (one click orders ascending, the next click orders descending.) at best this is confusing in the context of the application, and it might be reordering values as they are read back in to my permanent storage, since it only reorders a single column, not the entire row.
thanks,
jdcoburnAsked:
Who is Participating?
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
Set the SortMode property of the columns to NotSortable instead of the default Automatic value.
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,

if you want to disable sorting for a specific column then you can use SortExpression="" like following:

<asp:BoundField HeaderText="Header Name" DataField="FieldName" SortExpression="" />


and for complete grid you can use allowsorting="false"  as following:

<asp:gridview id="gv"
        allowsorting="false"
        runat="server">

Thanks
0
All Courses

From novice to tech pro — start learning today.