473,395 Members | 2,436 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,395 software developers and data experts.

GridView Blank with AllowPaging="True"

Okay, I spent about 3 hours getting the GridView control to do what I
needed.

Basically, I set the control's AutoGenerateColumns to False and then defined
a single template column (which I will customize with my own content). This
looks something like this:

<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="100%" AllowPaging="False"
OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Articles">
<ItemTemplate>
<b><%# Eval("art_name") %></b><br />
<%# Eval("art_desc") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Then, in my page's Load event, I run a database query and do something like
this:

SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();

I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It looks
fine in the IDE.)

I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.

Does anyone have any ideas?

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jan 29 '07 #1
4 6932
Jonathan,

I guess the problem is in using a SqlDataReader as a datasource. The msdn
library states that "the paging feature can be used with any data source
object that supports the System.Collections.ICollection interface or a data
source that supports paging capability". SqlDataReader is neither of them.
An example of a data source that supports paging capability is
SqlDataSource.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Okay, I spent about 3 hours getting the GridView control to do what I
needed.

Basically, I set the control's AutoGenerateColumns to False and then
defined a single template column (which I will customize with my own
content). This looks something like this:

<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="100%" AllowPaging="False"
OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Articles">
<ItemTemplate>
<b><%# Eval("art_name") %></b><br />
<%# Eval("art_desc") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Then, in my page's Load event, I run a database query and do something
like this:

SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();

I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It looks
fine in the IDE.)

I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.

Does anyone have any ideas?

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Jan 29 '07 #2
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It looks
fine in the IDE.)

I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.

Does anyone have any ideas?
You're using an SqlDataReader as the DataSource - can't do that if you want
paging.

Use a DataSet instead and all will be well.
Jan 29 '07 #3
That must be it. Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:uO**************@TK2MSFTNGP04.phx.gbl...
Jonathan,

I guess the problem is in using a SqlDataReader as a datasource. The msdn
library states that "the paging feature can be used with any data source
object that supports the System.Collections.ICollection interface or a
data source that supports paging capability". SqlDataReader is neither of
them. An example of a data source that supports paging capability is
SqlDataSource.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Okay, I spent about 3 hours getting the GridView control to do what I
needed.

Basically, I set the control's AutoGenerateColumns to False and then
defined a single template column (which I will customize with my own
content). This looks something like this:

<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="100%" AllowPaging="False"
OnPageIndexChanged="GridView1_PageIndexChanged" >
<Columns>
<asp:TemplateField HeaderText="Articles">
<ItemTemplate>
<b><%# Eval("art_name") %></b><br />
<%# Eval("art_desc") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Then, in my page's Load event, I run a database query and do something
like this:

SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();

I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It
looks fine in the IDE.)

I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.

Does anyone have any ideas?

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Jan 29 '07 #4
I'll look into using a DataSet instead.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It
looks fine in the IDE.)

I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.

Does anyone have any ideas?

You're using an SqlDataReader as the DataSource - can't do that if you
want paging.

Use a DataSet instead and all will be well.

Jan 29 '07 #5

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

Similar topics

1
by: Alex | last post by:
I created a page to show RealEstate Data with images retrived from the MSSQL 2000. I am using a DataGrid control: <asp:datagrid AllowPaging="True" OnPageIndexChanged="Pageindexchanged" > ...
4
by: John Baker | last post by:
Hi: I have a query which supports a form. Te form is used to edit, update and change records in the table the query is based on. It all works fine EXCEPT that the "New" record (blank updatable...
5
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash...
0
by: Kit Truong | last post by:
The page directive: <% @Page aspcompat="true" %> is causing my web pages to hang. (Page takes a very long time to load, and finally loads with a blank page) Everything was working yesterday...
0
by: Sachin | last post by:
Hi All, I am using ASP.NET 2.0 and GridView control. I have a stored procedure, SP_GetAllRows which takes the table name as parameter and fires the query "Select * from TableName" dynamically....
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
3
by: nick chan | last post by:
Hi i run into some difficulties getting rowupdating to fire when clicking Update link/button on gridview I set datasource at runtime, basically a datatable Edit and Cancel works. I don't know...
0
by: hhoang.nl | last post by:
I have a very weird problem with the GridView control. Here is the code: <asp:GridView runat="server" ID="gv" AutoGenerateEditButton="true" AutoGenerateSelectButton="true" AllowPaging="true"...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
agi2029
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,...

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.