473,937 Members | 4,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
I have problem on Gridview column sorting.I want to sort each column when click to the column head.I implemented the 'GridView1_Sort ing methond by using viewstate and in this way below.


Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
  2. {
  3.  
  4. //ViewState["sortDirection"] = e.SortExpression == (string)ViewState["sortExpression"] ? ((string)ViewState["sortDirection"] == "ASC" ? "DESC" : "ASC") : "ASC";
  5. //ViewState["sortExpression"] = e.SortExpression;
  6. //GridView1.DataBind();
  7.  
  8. if (ViewState["sortdirection"] == null)
  9. {
  10.    ViewState["sortdirection"] = "ASC";
  11. }
  12. else
  13. {
  14.    if (ViewState["sortdirection"].ToString() == "ASC")
  15.    {
  16.       ViewState["sortdirection"] = "DESC";
  17.    }
  18.    else
  19.    {
  20.       ViewState["sortdirection"] = "ASC";
  21.    }
  22. }
  23.  
  24. //Response.Write(ViewState["sortdirection"]);
  25.  
  26. GridView1.DataBind();
  27. }
  28.  
Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  2. {
  3. GridView1.PageIndex = e.NewPageIndex;
  4. GridView1.DataBind();
  5. }
  6.  

The GridView looks like
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
  2. AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnPageIndexChanging="GridView1_PageIndexChanging"
  3. Width="1214px" AllowSorting="True" OnSorting="GridView1_Sorting" PageSize="15">
  4.  
  5. <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
  6. <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
  7.  
It doesn't sort the column.What is the wrong at the "GridView1_Sort ing" method.I tried many ways,didn't get sorted.

Any help would be great.
Jul 8 '08 #1
0 2114

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5302
by: Arjen | last post by:
Hi, I databind my gridview like this: GridView1.DataSource = Membership.GetAllUsers(); // asp.net 2.0 (MembershipUserCollection) GridView1.DataBind(); When I try to sort the gridview I get this error message: The GridView 'GridView1' fired event Sorting which wasn't handled.
2
11145
by: Arjen | last post by:
Hi, I get this error message when sorting a gridview: The GridView 'GridView1' fired event Sorting which wasn't handled What do I need to do? Thanks!
2
16352
by: | last post by:
Hello, I have a GridView in my ASP.NET 2.0 application that performs the paging feature perfect when I have it bound to a data source. But now I have it bound to a dataset and the paging feature will not work. When I try to use paging I get this error: The GridView 'gvResults' fired event PageIndexChanging which wasn't handled.
5
15357
by: Brian McClellan | last post by:
Just wondering if anyone has a simple example of creating a gridview completely programmatically, i'm not doing anything terribly sophisticated. When creating the gridview declaratively evertying works fine, however programmatically, while the grid will display data that exsists in the database, any operation on the data ( editing/updating/deleting ) seems to cause a rowdeleting/updating etc error. Or is this simply not meant to be done?
5
2819
by: GaryDean | last post by:
I have a GridView that works fine when I bind it to an ObjectDataSource at design time. But if I bind it at run time nothing happens. On a button click event I say... GridView1.DataSourceID = ObjectDataSource1.ID; GridView1.DataBind(); What's missing? --
8
7749
by: gerry | last post by:
The PagerSettings.Visible property is not being handled properly by the GridView control. The value assigned to this property is not applied until after a postback. Simplest test : .aspx containing a single gridview - enable paging and give enough data to page. add checkbox with auto postback enable add button with auto postback enable in the GridView1_PreRender method add the following : GridView1.HeaderRow.Enabled =
4
12590
by: Tomasz | last post by:
Hello Developers, Here is interesting problem I just came across: how do I wire a GridView control programmatically? Here is my sample code using Object Data Source: protected void Page_Load(object sender, EventArgs e) { ObjectDataSource ods = new ObjectDataSource("MyTestTableAdapter",
2
6673
by: giveDsolution | last post by:
I want to sort the gridview by clicking the header but it shows the below error The GridView 'GridView1' fired event Sorting which wasn't handled.
1
2052
by: suganya | last post by:
I have displayed the data from the DB to the GridView made a column in the GridView as HyperLink allowed paging by setting the Allow Paging Property to "True". By clicking on the page no link I have to view other records. For that I have given the coding as protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } ...
0
10123
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
Hi, I have created a second gridview when customer clicks on select link with this code: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand Select Case e.CommandName
0
9959
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11278
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7377
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6277
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4898
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4441
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.