There was no XML code there, actually this was the code in .asox file. I think that you are dealing with an ASP.NET project and there you are having a code behinf file then you will be also having the web form or web control with an extension of .aspx or .ascx
If you are doing everything in the code behind then this would also work and you will need to something like this. DataGrid1.AllowSorting = true; DataGrid1.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.SortCommand); private void SortCommand(Object sender, DataGridSortCommandEventArgs e) { DataView dv = DataSet11.Tables(0).DefaultView; DataGrid1.DataSource = dv; dv.Sort = TextBox4.Tex; // I am assuming that you are putting the name of the field in this TextBox // on the basis of which you want to short the grid DataGrid1.DataBind(); } I hope this would help you. Rahul. -----Ursprüngliche Nachricht----- Von: franklin gray [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 7. Juni 2002 16:43 An: [EMAIL PROTECTED] Betreff: Re: [DOTNET] AW: [DOTNET] Sorting web grid I am using code behind so I don't think I can compair your xml to my code. Anyway, my problem seemed to be that I have to re-load the dataset in sort event. I am not used to using web pages so I forgot that the dataset isn't stateful. What is the normal way of handling a sortable grid handled...I am familar with the following but only done #1. 1) reloading the dataset from sql 2) adding the dataset to the session object 3) using cashed datasets. -----Original Message----- From: Rahul Sharma [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 9:25 AM To: [EMAIL PROTECTED] Subject: [DOTNET] AW: [DOTNET] Sorting web grid Hi, Try like this: (code is written with C#) private void SortCommand(Object sender, DataGridSortCommandEventArgs e) { DataView dv = Me.DataSet11.Tables(0).DefaultView; DataGrid1.DataSource = dv; dv.Sort = e.SortExpression; DataGrid1.DataBind(); } I hope that you are doing something like this in your DataGrid ASPX Code: <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="false" AllowSorting=True OnSortCommand="SortCommand"> <Columns> <asp:BoundColumn runat="server" DataField="TabName" HeaderText="Tab Name" SortExpression="TabName"/> <asp:BoundColumn runat="server" DataField="ClickCount" HeaderText="Click Count" SortExpression="ClickCount" /> <asp:TemplateColumn runat="server" HeaderText="Click Percent" SortExpression="ClickPercent"> <itemtemplate> <asp:Label ID=Label1 runat=server><%# DataBinder.Eval(Container.DataItem,"ClickPercent", ) %> </asp:Label> </itemtemplate> </Columns> </asp:datagrid> Or if you are not doing like this then this would be a good enough example to understand. Hope this helps you. Rahul. -----Ursprüngliche Nachricht----- Von: franklin gray [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 7. Juni 2002 15:32 An: [EMAIL PROTECTED] Betreff: [DOTNET] Sorting web grid How do I sort a web grid. I set the AllowSort property to true and tried to do the following in the Sort event, but I get a funny looking grid without any data. Private Sub DataGrid1_SortCommand(.....) Handles DataGrid1.SortCommand TextBox4.Text = e.SortExpression.ToString() Me.DataSet11.Tables(0).DefaultView.Sort = e.SortExpression.ToString Me.DataGrid1.DataSource = Me.DataSet11.Tables(0).DefaultView Me.DataGrid1.DataBind() End Sub You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.