Define the page level variable<BR>strSortOrder = "MyDefaultSortField"<BR><BR>In the data grid, specify<BR>AllowSorting=True<BR>OnSortCommand=Sort Rows<BR><BR>Also, <BR>In your BindData procedure, add<BR>objDataSet.Tables("YourTable").DefaultView. Sort = strSortOrder<BR><BR>Add a Sub called<BR><BR>Sub SortRows(ByVal sender As Object, ByVal objArgs as DataGridSortCommandEventArgs)<BR><BR> strSortOrder = objArgs.SortExpression.ToString()<BR> BindData()<BR><BR>End Sub<BR><BR><BR>AND<BR>If you have AutoGenerateColumns=False, you need to specify the <BR>SortExpression = "FieldName"<BR>for each column you want to sort by.
This article helped me learn to do sorting across pages if that's what you are asking. <BR><BR>http://www.dotnetbips.com/displayarticle.aspx?id=7<BR><BR>It is more difficult to get a stored procedure to have a different order by clause if this is the way you are doing it. I don't know of a way to add conditions around your order by clause if you are passing an order by parameter to you stored procedure. It seems like you would need some sort of decode fuction, try a SQL board if that's your problem. If you're not using paging just use the datagrid's build in sorting features. <BR>