Column Sort Help

Hello all, I'm trying to get my datagrid columns to sort. When you click the header of a certain field, it should sort ascending by that field. So far i've got this:


<script runat="server">
protected void dg_summary_SortCommand(Object sender, DataGridSortCommandEventArgs e) {
string sortDir="";
if (Request.QueryString["sortOn"]==e.SortExpression) {
if (Request.QueryString["sortDir"]=="") {
sortDir="ASC";
}
else if (Request.QueryString["sortDir"]=="ASC") {
sortDir="DESC";
}
else if (Request.QueryString["sortDir"]=="DESC") {
sortDir="ASC";
}
}
else {
sortDir="ASC";
}
Response.Redirect(Request.ServerVariables["SCRIPT_NAME"]+"?sortOn="+e.SortExpression+"&sortDir="+sortDir);
}
</script>


which fires using the OnSortCommand event handler. Now when you click the header of any field, you can see the page address change, reflecting htat the script is working; but the columns don't sort. They stay just as they are.
Can someone offer advice? I understand that this isn't the best way to make columns sort but I'm new to ASP.NET and I'm using this supplied code from a Macromedia tutorial.

Thanks for any help you can give me!you need to write the code that sorts your datatable that binds the grid.

Eric
 
Back
Top