472,983 Members | 2,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

Disappearing GridView Paging BUG!

Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging
without postbacks (or at least not documented how to fix it). Once the
GridView is displayed, clicking on any of the paging tools causes the
GridView to completely disappear! This happens when either DataSets or
DataTables are used (it doesn't work at all for DataReaders because they
don't support paging apparently).

If you remove the EnableSortingAndPageCallbacks parameter from the script
below and add a PageIndexChanging sub, the paging works fine except there is
a postback for every page. I would prefer to NOT have a postback and instead
use the the AJAX-like callbacks when EnableSortingAndPageCallbacks is
enabled.
Protected Sub AuthorsGridView_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles
AuthorsGridView.PageIndexChanging

AuthorsGridView.PageIndex = e.NewPageIndex

bindDataToGridView()

End Sub

So, how can you use GridView with callback paging without postbacks? What's
missing from the code and why shouldn't the code work? And where is the
documentation for avoiding this problem?

Thanks for any help.

<%@ Page language="VB" %>

<script runat="server">

Private Sub bindDataToGridView()
'This example uses Microsoft SQL Server and connects
Dim strSQL As String = "SELECT [au_fname], [au_lname], [city] FROM
[authors]"
Dim con As New
System.Data.SqlClient.SqlConnection("server=localh ost;database=pubs;integrated
security=SSPI")
Dim cmd = New System.Data.SqlClient.SqlCommand(strSQL, con)
Dim ad As New System.Data.SqlClient.SqlDataAdapter(cmd)

Dim ds As New Data.DataSet
'Dim dt As New Data.DataTable

ad.Fill(ds)
'ad.Fill(dt)

AuthorsGridView.DataSource = ds
'AuthorsGridView.DataSource = dt
AuthorsGridView.DataBind()
End Sub

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
bindDataToGridView()
End If
End Sub

</script>

<html>
<body>
<form id="Form1" runat="server">

<h3>Disappearing GridView Example</h3>

<asp:gridview id="AuthorsGridView"
autogeneratecolumns="False"
AllowPaging="True"
EnableSortingAndPagingCallbacks="True"
PageSize="3"
runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="au_fname" HeaderText="First Name">
</asp:BoundField>
<asp:BoundField DataField="au_lname" HeaderText="Last Name">
</asp:BoundField>
<asp:BoundField DataField="City" HeaderText="City">
</asp:BoundField>
</Columns>
<RowStyle BackColor="#E3EAEB" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:gridview>
</form>
</body>
</html>

Apr 13 '07 #1
0 1937

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

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
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...
1
by: Henry Habermacher [MVP Access] | last post by:
Environment: VS2005, ASP.Net 2.0, SQLServer 2000, VB.Net, IIS6 I use a GridView Control which is based on a SQLDataSource. The datasource is based on a Select statement and is filtered by the...
4
by: Chuck | last post by:
I'm setting the column with for a gridview (25+- columns) and have paging turned on. When the gridview is first displayed, the column widths are all set to the default. But after paging to...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
8
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...
3
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
4
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.