473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

datagrid paging buttons

I need to change the paging buttons in my C# web datagrid from "previous"
and "next" to something like "Records 10-20 of 100", etc., depending on
which page the user is on. Any ideas?

Thanks,
Dave
Nov 16 '05 #1
1 2780
Hi David,

You have to do it on your own, Here is some code that may help you
PD: I'm using strong typed collection as datasource for my grid, so the code
below WILL NOT COMPILE but it will give you an idea of how to do it

in the aspx file:
grid declaration, take a look as I set to false the paging

<tr><td>
<asp:datagrid id=accidentgrid runat="server" ShowHeader="false"
PagerStyle-Visible="False"
visible="true" showfooter="False" autoGenerateColumns="False"
BackColor="white" CellSpacing="0" GridLines="None" >
</asp:datagrid>
</td></tr>

<tr><td>
<!--
Here is the pagination code, it consist of two LinkButtons whose
properties ( enable) are set dynamically depending of the datasource
-->
<asp:LinkButton OnClick="GotoPreviousPage" CssClass="purple"
Enabled="<%#ExistPreviousPage() %>" id=LinkButton1 runat="server">
&lt;- Prev</asp:LinkButton>
&nbsp;
&nbsp;
<asp:LinkButton OnClick="GotoNextPage" CssClass="purple"
Enabled="<%#ExistNextPagePage() %>" id="Linkbutton2"
runat="server">Next -&gt; </asp:LinkButton>
</td></tr>

Now in the code behind I define the function used to know the paging and do
the pagination itself.:
Code behind code:
protected bool ExistPreviousPage()
{
return accidentgrid.CurrentPageIndex>0;
}

protected void GotoPreviousPage(object sender, System.EventArgs e)
{
accidentgrid.CurrentPageIndex -=1;
GridContainer.DataBind();
}
protected bool ExistNextPagePage()
{
return accidentgrid.CurrentPageIndex< accidentgrid.PageCount-1;
}
protected void GotoNextPage(object sender, System.EventArgs e)
{
accidentgrid.CurrentPageIndex +=1;
GridContainer.DataBind();
}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"David Petersen" <da*******@hotmail.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
I need to change the paging buttons in my C# web datagrid from "previous"
and "next" to something like "Records 10-20 of 100", etc., depending on
which page the user is on. Any ideas?

Thanks,
Dave

Nov 16 '05 #2

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

Similar topics

0
by: Ricardo Manuel | last post by:
Hi, I'm using a Datagrid that I fill with a Dataset but when I configure the paging with the Navigation Buttons I can't put them working, I've tried both methods (Next, Previous and Page Numbers)...
2
by: Ricardo Manuel | last post by:
Hi, I'm using a Datagrid that I fill with a Dataset but when I configure the paging with the Navigation Buttons I can't put them working, I've tried both methods (Next, Previous and Page Numbers)...
1
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). This code doesn't even run unless a button in...
1
by: David Petersen | last post by:
I need to change the paging buttons in my C# web datagrid from "previous" and "next" to something like "Records 10-20 of 100", etc., depending on which page the user is on. Any ideas? Thanks,...
2
by: George Durzi | last post by:
Is there a way to implement datagrid paging without using javascript on the client-side?
2
by: Daniel Walzenbach | last post by:
Hi, I have a question regarding the DataGrid control. If paging is enabled the grid binds the data, sets the paging on the top/bottom (or however it is set up) and throws away unnecessary...
4
by: Daniel | last post by:
Hi All, I need to change the "1 2 3 4..." link button page browsing to 2 buttons which are "<" button and ">" button. is it possible? any guidelines? your help will be appreciated. thank...
1
by: the friendly display name | last post by:
Simple question: How to make datagrid paging work without javascript? I have a simple datagrid, which gets populated by a dataview, it works perfectly, paging works too, but, as I said, it...
3
by: archana | last post by:
Hi all, Can anyone tell me what exactly VirtualItemCount in datagrid. I read on msdn but not clear about it. Any help will be truely appreciared. thanks in advance
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
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 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.