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.