The GridView 'GridView1' fired event Sorting which wasn't handled.

Discussion in 'Software' started by rajendrasedhain, Jul 8, 2008.

  1. rajendrasedhain

    rajendrasedhain

    Joined:
    Jul 8, 2008
    Messages:
    1
    I have problem on Gridview column sorting.I want to sort each column when click to the column head.I implemented the 'GridView1_Sorting methond by using viewstate and in this way below.



    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)

    {

    //ViewState["sortDirection"] = e.SortExpression == (string)ViewState["sortExpression"] ? ((string)ViewState["sortDirection"] == "ASC" ? "DESC" : "ASC") : "ASC";

    //ViewState["sortExpression"] = e.SortExpression;

    //GridView1.DataBind();



    if (ViewState["sortdirection"] == null)

    {

    ViewState["sortdirection"] = "ASC";

    }

    else

    {

    if (ViewState["sortdirection"].ToString() == "ASC")

    {

    ViewState["sortdirection"] = "DESC";

    }

    else

    {

    ViewState["sortdirection"] = "ASC";

    }

    }

    //Response.Write(ViewState["sortdirection"]);

    GridView1.DataBind();

    }



    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

    {

    GridView1.PageIndex = e.NewPageIndex;

    GridView1.DataBind();

    }



    The GridView looks like

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"

    AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnPageIndexChanging="GridView1_PageIndexChanging"

    Width="1214px" AllowSorting="True" OnSorting="GridView1_Sorting" PageSize="15">

    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />

    <RowStyle BackColor="#DEDFDE" ForeColor="Black" />



    It doesn't sort the column.What is the wrong at the "GridView1_Sorting" method.I tried many ways,didn't get sorted.

    Any help would be great.
     
    rajendrasedhain, Jul 8, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cogito
    Replies:
    4
    Views:
    466
    Cogito
    May 17, 2005
  2. Dan
    Replies:
    0
    Views:
    409
  3. Dan
    Replies:
    1
    Views:
    493
    Canopus
    Jun 26, 2007
  4. Anumitha
    Replies:
    1
    Views:
    3,110
  5. digger odell

    Using a program which wasn't installed?

    digger odell, Oct 6, 2010, in forum: Computer Support
    Replies:
    6
    Views:
    447
    Meat Plow
    Oct 7, 2010
Loading...

Share This Page