PC Review


Reply
Thread Tools Rate Thread

DataGrid Paging makes DataGrid Disappear

 
 
smithb1028
Guest
Posts: n/a
 
      27th Jan 2007
I have a simple DataGrid and trying to get paging to work. I
orginially want to use this in an AJAX UpdatePanel, but I moved it out
of it until I get it to work.

This is the DataGrid in the ASPX:

<aspataGrid ID="dgActiveVisits" AutoGenerateColumns="true"
AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChanged="dgActiveVisits_PageIndexChanged" runat="server">
<HeaderStyle BackColor="Gray"
ForeColor="White" />
</aspataGrid>

The C# code behind:

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dgActiveVisits.CurrentPageIndex = 0;
BindData();
}
}

protected void dgActiveVisits_PageIndexChanged(object sender,
DataGridPageChangedEventArgs e)
{
dgActiveVisits.CurrentPageIndex = e.NewPageIndex;
BindData();
}

void BindData()
{
DataTable dt = new DataTable();
// removed DataTable setup, has 15 rows

dgActiveVisits.DataSource = dt;
dgActiveVisits.DataBind();
}

When the page first loads, it loads the first page of data just fine.
But when I click Next, the entire DataGrid just disappears... At first
I thought there was an issue with the UpdatePanel, but after taking it
out of the UpdatePanel it still displays this same behavior... I
looked all over the internet and followed their examples exactly...

Any help would be greatly appreciated...

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      27th Jan 2007
Try using the PageIndexChanging event instead.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"smithb1028" wrote:

> I have a simple DataGrid and trying to get paging to work. I
> orginially want to use this in an AJAX UpdatePanel, but I moved it out
> of it until I get it to work.
>
> This is the DataGrid in the ASPX:
>
> <aspataGrid ID="dgActiveVisits" AutoGenerateColumns="true"
> AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
> CellPadding="3" CellSpacing="0"
> OnPageIndexChanged="dgActiveVisits_PageIndexChanged" runat="server">
> <HeaderStyle BackColor="Gray"
> ForeColor="White" />
> </aspataGrid>
>
> The C# code behind:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!Page.IsPostBack)
> {
> dgActiveVisits.CurrentPageIndex = 0;
> BindData();
> }
> }
>
> protected void dgActiveVisits_PageIndexChanged(object sender,
> DataGridPageChangedEventArgs e)
> {
> dgActiveVisits.CurrentPageIndex = e.NewPageIndex;
> BindData();
> }
>
> void BindData()
> {
> DataTable dt = new DataTable();
> // removed DataTable setup, has 15 rows
>
> dgActiveVisits.DataSource = dt;
> dgActiveVisits.DataBind();
> }
>
> When the page first loads, it loads the first page of data just fine.
> But when I click Next, the entire DataGrid just disappears... At first
> I thought there was an issue with the UpdatePanel, but after taking it
> out of the UpdatePanel it still displays this same behavior... I
> looked all over the internet and followed their examples exactly...
>
> Any help would be greatly appreciated...
>
>

 
Reply With Quote
 
smithb1028
Guest
Posts: n/a
 
      28th Jan 2007
There isn't a PageIndexChanging event, not in VS IDE, anyway.

Brad

 
Reply With Quote
 
smithb1028
Guest
Posts: n/a
 
      28th Jan 2007
Also, you'll notice on the Page_Load it sets the current index to 0.
If I change that to 1 or 2, it does display the appropriate page of
data on first load. But again, moving back or next causes the entire
DataGrid to disappear...

The only thing I'm doing differently from previous apps, is I have
added the AJAX extensions to the web.config and I've installed SP1 for
VS 2005.

I can not, for the life of me, see the problem. Any help is much
appreciated...


Brad

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      28th Jan 2007
"Peter Bromberg [C# MVP]" <(E-Mail Removed)> wrote in
message news:A4B8D2D6-6234-481E-9D35-(E-Mail Removed)...

> Try using the PageIndexChanging event instead.


The OP is talking about a DataGrid, not a GridView...


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      28th Jan 2007
"smithb1028" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> There isn't a PageIndexChanging event, not in VS IDE, anyway.


Peter meant to say PageIndexChanged
http://msdn2.microsoft.com/en-us/lib...exchanged.aspx


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      28th Jan 2007
"smithb1028" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I can not, for the life of me, see the problem. Any help is much
> appreciated...


Put a breakpoint on the line

dgActiveVisits.DataSource = dt;

and interrogate the dt.Rows.Count property...


 
Reply With Quote
 
smithb1028
Guest
Posts: n/a
 
      28th Jan 2007
So I copied paste the code into a new Web Form and, of course, it
worked... So I'll just build the rest around it now... I have some
other issues but will post them in a new thread because they are
related to different controls.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid.Items.Count and DataGrid Paging... Green Start Button Microsoft ASP .NET 1 4th Aug 2005 08:40 PM
Combining numeric mode paging and nextPreview paging in datagrid Red Microsoft ASP .NET 1 12th Mar 2005 11:41 PM
datagrid paging - customising paging style wh1974 Microsoft ASP .NET 0 12th Jan 2005 03:48 PM
datagrid , SQL Reader and Paging... Datagrid disappears Roger Microsoft ASP .NET 0 28th Dec 2004 04:05 PM
Using DataGrid in a form makes the TopMost property invalid -- DataGrid bug? Sajjadul Hakim Microsoft C# .NET 0 5th Apr 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 AM.