473,388 Members | 986 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,388 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 6930
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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,...

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.