Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > The GridView 'GridView1' fired event Sorting which wasn't handled.

Reply
Thread Tools

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

 
 
rajendrasedhain rajendrasedhain is offline
Junior Member
Join Date: Jul 2008
Posts: 1
 
      07-08-2008
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Gridview1' fired event Sorting which wasn't handled Vincent ASP .Net 12 03-19-2010 04:35 PM
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
The GridView 'GridView2' fired event RowEditing which wasn't handl egsdar ASP .Net 0 11-04-2008 04:51 PM
The GridView 'GridView1' fired event Sorting which wasn't handled Arjen ASP .Net 3 11-01-2007 11:13 PM
fired event Sorting which wasn't handled - sorting and SelectedIndexChanged Jason ASP .Net Web Controls 0 10-04-2006 02:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57