Disable Sorting In DataGridView

  • Thread starter Thread starter joey.powell
  • Start date Start date
J

joey.powell

Does anyone know how to disable sorting in a datagridview? I mean, when
a user clicks a column header, the rows should not reorder.
 
Did you try removing the SortExpression in the aspx page?

<asp:BoundField DataField="EmpID" HeaderText="The Employee ID" />

<asp:BoundField DataField="EmpID" HeaderText="The Employee ID"
SortExpression="EmpID"/>
 
Joey,

You will have to cycle through each of the columns on the grid and set
the SortMode property to DataGridViewColumnSortMode.NotSortable.

Hope this helps.
 
That did it. Thanks a lot!
Joey,

You will have to cycle through each of the columns on the grid and set
the SortMode property to DataGridViewColumnSortMode.NotSortable.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Does anyone know how to disable sorting in a datagridview? I mean, when
a user clicks a column header, the rows should not reorder.
 
Back
Top