See:http://www.microsoft.com/china/community/Column/23.mspx

解决方案 »

  1.   

    下面方法可以实现正排序或倒排序
    Private Sub DataGrid2_SortCommand1(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid2.SortCommand
            If Session("sort") = "0" Or IsNothing(Session("sort")) Then
                databind(e.SortExpression)
                Session("sort") = "1"
            Else
                databind(e.SortExpression & " DESC")
                Session("sort") = "0"
            End If
    End Sub   Private Sub show_receive(ByVal source As String)
            Dim ds As New DataSet
            Dim dataview1 As DataView
            DAinformation = New SqlDataAdapter(Select_Information, myconnect)
            DAinformation.Fill(ds, "receive")        dataview1 = ds.Tables("receive").DefaultView
            dataview1.Sort = source
            DataGrid2.DataSource = dataview1
            DataGrid2.DataBind()
    ......................................
      

  2.   

    我这里有C#实现的排序,你可以参考一下:
    private void Page_Load(object sender, System.EventArgs e)
    {
        if(!IsPostBack)
        {
    BindData("你要按该列排序的列名");
        }
    }public void BindData(string SortOrder)
    {
        ......
        dataSet1.Tables["表名"].DefaultView.Sort=SortOrder;
    }
    ......
    private void DataGrid1_SortCommand(object source, DataGridSortCommandEventArgs e)
    {
    string SortOrder1=e.SortExpression.ToString();
    BindData(SortOrder1);
    }
      

  3.   

    同意jedliu(),当然你可以不传参数,用VIEWSTATE来实现
      

  4.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=E5254FD8-252F-457C-F61E-32EE353E8BF2