473,699 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Paging makes DataGrid Disappear

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="dgActiveVis its" AutoGenerateCol umns="true"
AllowPaging="tr ue" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChan ged="dgActiveVi sits_PageIndexC hanged" runat="server">
<HeaderStyle BackColor="Gray "
ForeColor="Whit e" />
</asp:DataGrid>

The C# code behind:

protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
dgActiveVisits. CurrentPageInde x = 0;
BindData();
}
}

protected void dgActiveVisits_ PageIndexChange d(object sender,
DataGridPageCha ngedEventArgs e)
{
dgActiveVisits. CurrentPageInde x = 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...

Jan 27 '07 #1
7 4252
Try using the PageIndexChangi ng 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="dgActiveVis its" AutoGenerateCol umns="true"
AllowPaging="tr ue" PageSize="5" Width="100%" BorderWidth="0"
CellPadding="3" CellSpacing="0"
OnPageIndexChan ged="dgActiveVi sits_PageIndexC hanged" runat="server">
<HeaderStyle BackColor="Gray "
ForeColor="Whit e" />
</asp:DataGrid>

The C# code behind:

protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
dgActiveVisits. CurrentPageInde x = 0;
BindData();
}
}

protected void dgActiveVisits_ PageIndexChange d(object sender,
DataGridPageCha ngedEventArgs e)
{
dgActiveVisits. CurrentPageInde x = 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...

Jan 27 '07 #2
There isn't a PageIndexChangi ng event, not in VS IDE, anyway.

Brad

Jan 28 '07 #3
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

Jan 28 '07 #4
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comwrote in
message news:A4******** *************** ***********@mic rosoft.com...
Try using the PageIndexChangi ng event instead.
The OP is talking about a DataGrid, not a GridView...
Jan 28 '07 #5
"smithb1028 " <sm****@intrepi darch.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
There isn't a PageIndexChangi ng event, not in VS IDE, anyway.
Peter meant to say PageIndexChange d
http://msdn2.microsoft.com/en-us/lib...exchanged.aspx
Jan 28 '07 #6
"smithb1028 " <sm****@intrepi darch.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.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...
Jan 28 '07 #7
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.

Jan 28 '07 #8

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

Similar topics

2
3569
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. I'm styling it on the HTML page. I configure the DataGrid for paging through the property builder fine. I AllowCustomePaging=true;. The page loads fine but it only shows "1"
2
3151
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 myBoundColumnEntryBy As New BoundColumn() myBoundColumnEntryBy.DataField = "Entry By" myBoundColumnEntryBy.SortExpression = "Entry By"
2
2579
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 to be scrolled down completely to see the page number links. The page number should always be visible outside the scroll bar. Basically I want to create the paging links dynamically and on click of this it should fire PageIndexChanged event.
6
1813
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 fills the temp table again and returns rows 10-19. The temp table is dropped after each call to the SP, so it has to be created and filled every time the user changes page in the datagrid. My question is this: Would it be more efficient to...
2
1859
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 navigation links use JavaScript to jump between pages. I want them to use standard hyperlinks providing the page number in some URL parameter so that I can copy the hyperlink elsewhere.
5
2785
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 to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
1
1255
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 Thanks
0
1340
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 populates the data in the Details DataGrid (I'm using Dim Filter As String = CStr(dtgMaster.DataKeys(dtgMaster.SelectedIndex)).Replace("'", "''") to filter btw the Datagrids)
6
1844
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 to different page on one of the grids, all the other Grids loose data on on postback. I am binding all the grids on the Page_Load event of the page the
0
8685
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.