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:
<asp:DataGrid ID="dgActiveVisits" AutoGenerateColumns="true"
AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChanged="dgActiveVisits_PageIndexChange d" runat="server">
<HeaderStyle BackColor="Gray"
ForeColor="White" />
</asp:DataGrid>
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... 7 4244
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:
<asp:DataGrid ID="dgActiveVisits" AutoGenerateColumns="true"
AllowPaging="true" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChanged="dgActiveVisits_PageIndexChange d" runat="server">
<HeaderStyle BackColor="Gray"
ForeColor="White" />
</asp:DataGrid>
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...
There isn't a PageIndexChanging event, not in VS IDE, anyway.
Brad
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
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:A4**********************************@microsof t.com...
Try using the PageIndexChanging event instead.
The OP is talking about a DataGrid, not a GridView...
"smithb1028" <sm****@intrepidarch.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
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
"smithb1028" <sm****@intrepidarch.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
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...
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: RelaxoRy |
last post by:
sqlConnection1.Open();
myReader = sqlCommand1.ExecuteReader();
DataGrid1.DataSource = myReader;
DataGrid1.DataBind();
myReader.Close();
sqlConnection1.Close();
The Datagrid populates fine. ...
|
by: Hajime Kusakabe |
last post by:
Hi.
I have created a datagrid (datagrid1) without any columns on a aspx page.
Then aspx.vb adds columns from a database.
It is somthing like this ....
==================================
Dim...
|
by: RJN |
last post by:
Hi
Sorry for posting again.
I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has...
|
by: Shawn |
last post by:
Hi.
I already have a datagrid where I'm using paging. I have a stored procedure
that fills a temp table with 200-500 rows and then sends back 10 records at
the time. When I go to page 2 the SP...
|
by: Axel Dahmen |
last post by:
Hi,
I'm using a DataGrid control to show a table's content with paging. For
navigation through the pages I'm using the DataGrid's intrinsic navigation
section.
My problem: The DataGrid...
|
by: tshad |
last post by:
Is there a way to carry data that I have already read from the datagrid from
page to page?
I am looking at my Datagrid that I page through and when the user says get
the next page, I have to go...
|
by: Jon Turner |
last post by:
is there anyway to trap the client side paging event of the DataGrid in
JavaScript ?
If the user makes a change to a row, I want to warn them they will
lose changes before they page.
Many...
|
by: Pat |
last post by:
I have 3 Datagrid nested.
Master
Details
Child
The master has paging (And i'm using the paging inbuilt in the Datagrid)
in the Master DataGrid you select a linkbutton(using commandname) and it...
|
by: SatishPasala |
last post by:
Hi
I tried all the things I know am out of ideas now. Can you guys help
me out with this?
I have 4 grids on a page with I load on the Page_Load event. One of
the grids has paging. When I move...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |