Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   The GridView 'GridView1' fired event Sorting which wasn't handled. (http://www.velocityreviews.com/forums/t624472-the-gridview-gridview1-fired-event-sorting-which-wasnt-handled.html)

rajendrasedhain 07-08-2008 07:52 PM

The GridView 'GridView1' fired event Sorting which wasn't handled.
 
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.


All times are GMT. The time now is 11:00 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.