Sort DataGrid by Clicking Column Header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sandy

    Sort DataGrid by Clicking Column Header

    Within my tag: <asp:DataGrid
    I'm using: AllowSorting="t rue" and
    OnSortCommand=" Sort_Grid" which referrs to a method in my
    Codebehind file. (see Sort_Grid below)
    Since I have AutoGenerateCol umns="false"
    within my tag: <asp:BoundColum n
    I'm using: DataField="name " SortExpression= "name"

    This doesn't generate an error, but when I click on the
    column heading I get:
    System.Web.Http Exception: The View State is invalid for
    this page and might be corrupted.

    I do not know how to fix this problem. I am not using
    any ViewState in my code. Any guidance is appreciated,
    Thanks!




    public void Sort_Grid(Objec t sender,
    DataGridSortCom mandEventArgs e)
    {
    DataView dv = new DataView(dsAcco unts.Tables["account"]);
    dv.Sort = e.SortExpressio n;
    //DataGrid = dgAccounts
    dgAccounts.Data Source = dv;
    dgAccounts.Data Bind();

Working...