473,486 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

EnableSortingandPagingCallback when


I have a gridview that is refreshes when a dropdown is selected outside
of it. Sorting is enabled on the gridview but not working.

I read that I should set EnableSortingandPagingCallback to true to fix
the error:

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

However, I am now getting:

Callbacks are not supported on CommandField when the select button is
enabled because other controls on your page that are dependent on the
selected value of 'RatePlanGridView' for their rendering will not
update in a callback. Turn callbacks off on 'RatePlanGridView'.

Paging on the gridview appears to work fine, because I added these:

Protected Sub RatePlanGridView_PageIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
RatePlanGridView.PageIndexChanged
.. and I rebind (but I don't see code to set the new page)

End If

Protected Sub RatePlanGridView_PageIndexChanging(ByVal sender As
Object, ByVal e As GridViewPageEventArgs) Handles
RatePlanGridView.PageIndexChanging
RatePlanGridView.PageIndex = e.NewPageIndex
RatePlanGridView.DataBind()
End Sub
I get the noted error under

Protected Sub RouteCodesList_SelectedIndexChanged
when I attempt to bind.
The gridview is configured as follows:

<asp:GridView ID="RatePlanGridView" runat="server"
AutoGenerateColumns="False" DataKeyNames="RouteCode"
Width="700px" SkinID="GridView"
AllowPaging="True" AllowSorting="true" ShowFooter="true"
PagerSettings-Mode="NumericFirstLast">
Is there an event for sorting I should set, and will I have to take of
sorting myself?

Oct 23 '06 #1
2 6914
onsorting="Gridview_sorting"

and

Protected Sub GridView_Sorting(ByVal sender As Object, ByVal e As
GridViewSortEventArgs)
...

End Sub

Can somebody point me in the right direction in how to finish this, I
presume with e.sortdirection and/or e.sortexpression. I found some C#
code I tried to convert, but vb.net knows nothing about
ConversionHelpers or CovertSortDirectionToSQL. I am unclear about how
the sorting is even going to work.

Protected Sub RatePlanGridView_Sorting(ByVal sender As Object,
ByVal e As GridViewSortEventArgs)
Dim dataTable As DataTable =
CType(ConversionHelpers.AsWorkaround(RatePlanGridV iew.DataSource,
GetType(DataTable)), DataTable)
If Not (dataTable Is Nothing) Then
Dim dataView As DataView = New DataView(dataTable)
dataView.Sort = e.SortExpression + " " +
ConvertSortDirectionToSql(e.SortDirection)
RatePlanGridView.DataSource = dataView
RatePlanGridView.DataBind()
End If

Oct 23 '06 #2
The Grid displays with multiple rows. I select to sort of a particular
field and the below event is fired, but DataTable is Nothing so code is
skipped.
Protected Sub ChargeGridView_Sorting(ByVal sender As Object, ByVal e
As GridViewSortEventArgs)
Dim dataTable As DataTable = CType(ChargeGridView.DataSource,
DataTable)
If Not (dataTable Is Nothing) Then '****** (THIS IS ALWAYS
FALSE) ****
Dim dataView As DataView = New DataView(dataTable)
dataView.Sort = e.SortExpression + " " + e.SortDirection
Response.Write(e.SortExpression + " " + e.SortDirection)
ChargeGridView.DataSource = dataView
ChargeGridView.DataBind()
End If
End Sub

The GridView:

<asp:GridView ID="ChargeGridView" runat="server"
AutoGenerateColumns="False" DataKeyNames="RouteCode"
Width="700px" SkinID="GridView"
AllowPaging="True" AllowSorting="true"
OnSorting="ChargeGridView_Sorting" ShowFooter="true"
PagerSettings-Mode="NumericFirstLast">

Oct 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2641
by: Dynamo | last post by:
Hi, I am still confused as when to use single or double quotes. This works: echo "<td>" . $row . "</td>"; and this does not
4
12487
by: Nuno | last post by:
Is there any SQL Error? Or I have to use Select case in VB code to control SQL instead. Thank you for any ans. Nuno
2
18278
by: Halldór Ísak Gylfason | last post by:
In my application I have an iframe that is empty (and not visible) initially, however when a user presses a button a form is programmatically submitted and the target is set to the IFrame. I...
7
19921
by: sql-db2-dba | last post by:
Does DB2 just fudge it when it is an empty table? Is there a "formula" for average row size when you have variable length records. Or you really have to know what your application is packing into...
4
5898
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
5
555
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
8
2538
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
44
8159
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable...
0
6964
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...
0
7126
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,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
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...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.