473,387 Members | 1,545 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,387 software developers and data experts.

Paging Datagrid - Prev / Next will not appear as links

Dear Groups

I've used paging with a datagrid in C# at least a hundred times, but
for whatever reason, I cannot get the prev /next to appear as links.
It is absolutely certain that the number of records exceed the page
size.

Code is as follows:

<asp:datagrid id="grdStores" runat="server" allowpaging="True"
autogeneratecolumns="False" allowcustompaging="True"">
<alternatingitemstyle backcolor="#F0F1F3"></alternatingitemstyle>
<itemstyle cssclass="grdrow"></itemstyle>
<headerstyle cssclass="grdheader"></headerstyle>
<columns>
<asp:boundcolumn datafield="Name" headertext="Store Name">
<itemstyle width="25%"></itemstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="Address" headertext="Store Address">
<itemstyle width="50%"></itemstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="City" headertext="City">
<itemstyle width="20%"></itemstyle>
</asp:boundcolumn>
<asp:templatecolumn>
<headerstyle cssclass="grdheader"></headerstyle>
<itemstyle width="15px"></itemstyle>
<itemtemplate>
<asp:linkbutton id="lnkEdit" commandname="Edit" commandargument='<%#
DataBinder.Eval(Container.DataItem, "storeid" ) %>'
runat=server>Edit</asp:linkbutton>
</itemtemplate>
</asp:templatecolumn>
</columns>
<pagerstyle nextpagetext="Next" prevpagetext="Prev"></pagerstyle>
</asp:datagrid>

Databinding
SqlConnection connLC;
SqlCommand cmd;
SqlDataReader dtrCombos;
connLC = new
SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
connLC.Open();
string cSql="Select * from stores order by Name";
cmd = new SqlCommand(cSql , connLC);
dtrCombos = cmd.ExecuteReader();
if (dtrCombos.Read())
{
dtrCombos.Close();
dtrCombos = cmd.ExecuteReader();
grdStores.DataSource=dtrCombos;
grdStores.DataBind();
}
dtrCombos.Close();
connLC.Close();

Thanks in advance,

Darren

Nov 19 '05 #1
3 1437
As you have custom paging enabled (allowcustompaging="true"), you should
tell the exact row count for the grid via VirtualItemCount property. Another
thing being that paging with a datareader can get difficult.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #2
Set AllowPaging="True"

U have allowcustompaging="True" , are u using custom paging??
--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"Darren" wrote:
Dear Groups

I've used paging with a datagrid in C# at least a hundred times, but
for whatever reason, I cannot get the prev /next to appear as links.
It is absolutely certain that the number of records exceed the page
size.

Code is as follows:

<asp:datagrid id="grdStores" runat="server" allowpaging="True"
autogeneratecolumns="False" allowcustompaging="True"">
<alternatingitemstyle backcolor="#F0F1F3"></alternatingitemstyle>
<itemstyle cssclass="grdrow"></itemstyle>
<headerstyle cssclass="grdheader"></headerstyle>
<columns>
<asp:boundcolumn datafield="Name" headertext="Store Name">
<itemstyle width="25%"></itemstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="Address" headertext="Store Address">
<itemstyle width="50%"></itemstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="City" headertext="City">
<itemstyle width="20%"></itemstyle>
</asp:boundcolumn>
<asp:templatecolumn>
<headerstyle cssclass="grdheader"></headerstyle>
<itemstyle width="15px"></itemstyle>
<itemtemplate>
<asp:linkbutton id="lnkEdit" commandname="Edit" commandargument='<%#
DataBinder.Eval(Container.DataItem, "storeid" ) %>'
runat=server>Edit</asp:linkbutton>
</itemtemplate>
</asp:templatecolumn>
</columns>
<pagerstyle nextpagetext="Next" prevpagetext="Prev"></pagerstyle>
</asp:datagrid>

Databinding
SqlConnection connLC;
SqlCommand cmd;
SqlDataReader dtrCombos;
connLC = new
SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
connLC.Open();
string cSql="Select * from stores order by Name";
cmd = new SqlCommand(cSql , connLC);
dtrCombos = cmd.ExecuteReader();
if (dtrCombos.Read())
{
dtrCombos.Close();
dtrCombos = cmd.ExecuteReader();
grdStores.DataSource=dtrCombos;
grdStores.DataBind();
}
dtrCombos.Close();
connLC.Close();

Thanks in advance,

Darren

Nov 19 '05 #3
Thanks for your assistance everyone. Absolutely, using the datareader
in this scenario was problematic. I switched to a dataset and problem
solved. Thanks again.

Darren

Nov 19 '05 #4

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

Similar topics

2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
0
by: Mark | last post by:
I need some advice on how to acheive the desired result of my custom page link generation. The datagrid 'built-in' page navigation only allows either the 'Prev/Next' or the page numbers. ...
1
by: Dan Nash | last post by:
Hi guys Just developing a cool list that pulls data from an SQL database. I've got a nice header, a footer, borders down the side, but no top/bottom borders for the rows, and onmouseover /...
1
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...
2
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...
4
by: Happy | last post by:
hi I got a datagrid with Paging enabled which is getting populated thru a stored proc. I've given the code in the event grid.CurrentPageIndex = e.NewPageIndex grid.VirtualItemCount =...
0
by: richard | last post by:
OK, Im finished pulling my hair out and now I need help. I have created a VB class file for my custom paging, in it I create a table with 2 rows, in the rows I have linkbuttons for first page,...
1
osward
by: osward | last post by:
Hi all, I got code over the net for paging mysql table, it provides Prev pages Next link at the bottom of the table. However, I have a pretty large table to display (average over 400+ rows). Even...
3
osward
by: osward | last post by:
Hi, everyone, I had managed to make use of the date link from a simple calendar script to my query table. When I click on the date's link or Prev and Next Month link, The table first row will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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...
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.