Disappearing GridView - Newsgroup???



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 problems?

Thanks.


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=localhost;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>




.



Relevant Pages

  • RE: Problem with a Gridview
    ... I have a GridView that has one column that I fill with an alternating "Title ... Row" then "Details Row". ... Protected Sub Page_Load(ByVal sender As Object, ... Dim dt As New DataTable ...
    (microsoft.public.dotnet.framework.aspnet)
  • Pulling from Access Query, Cannot Change Date/Time Formats
    ... The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other. ... Sub doColor ... Dim i9, i10 As Integer ... I temporarily copied the access database into a sql database and had a stored proc that formatted the data with SQL code, ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Dynamic template for a delete button in gridview
    ... as for dynamic created GridView Fields(just like the dynamic created ... Dynamic template for a delete button in gridview ... | Dim selectfield As New CommandField ... | Sub BuildDelete ...
    (microsoft.public.dotnet.framework.aspnet)
  • Disappearing GridView Paging BUG!
    ... Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging ... Protected Sub AuthorsGridView_PageIndexChanging(ByVal sender As Object, ... how can you use GridView with callback paging without postbacks? ...
    (microsoft.public.dotnet.framework.aspnet)
  • GridView onmouseout problem
    ... original colour of the datagrid on mouseout. ... gridview - when i do a onmouseout all rows now go to a white backgound ... The first sub shows the code that works in my datagrid and the second ... Dim dcCol As DataColumn ...
    (microsoft.public.dotnet.languages.vb)