470,584 Members | 2,429 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,584 developers. It's quick & easy.

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
Protected Sub AuthorsGridView_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles

AuthorsGridView.PageIndex = e.NewPageIndex


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
Dim con As New
System.Data.SqlClient.SqlConnection("server=localh ost;database=pubs;integrated
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


AuthorsGridView.DataSource = ds
'AuthorsGridView.DataSource = dt
End Sub

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


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

<h3>Disappearing GridView Example</h3>

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

Apr 13 '07 #1
0 1788

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Henry Habermacher [MVP Access] | last post: by
4 posts views Thread by Chuck | last post: by
8 posts views Thread by Greg Lyles | last post: by
2 posts views Thread by antonyliu2002 | last post: by
4 posts views Thread by Don Miller | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.