Disable Sorting In DataGridView

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.
 
S

sloan

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"/>
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
J

joey.powell

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top