473,387 Members | 1,515 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-enabled GridView disappears at postback

I've been googling for some time, and could not find the solution to
this problem.

I am testing the paging feature of gridview. I have a very simple web
form on which the user can select a few fields to be included in the
table, which is to be bound to the gridview.

The web form looks like so (Don't worry about the stupidity of this
web form for now.):

Check stuffs you wanna include in the table:

[] Customer ID
[] Customer Last Name
[] Customer First Name
[] Customer Email
[] Customer Phone

[Click this button to show the table]

[---- the paging-enabled gridview is right here ------]

The gridview is declared like so:

<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>

In the code-behind (in C#), I pass the programmatically created SQL
select command to the SqlDataSource like so:

SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;

Now, after the user clicks the button to create the customer report,
the gridview is populated with customer data with the expected fields.

But, when the paging index is clicked, the gridview disaapears. One
short note from a blog says that gridview will disappear between
postbacks. So, this might be the cause.

I guess I don't need to implement a GridView1_OnPageIndexChanging
method to handle the paging event since I don't think I am manually
binding the gridview to the dataset.

How do we handle this problem? Thanks.

Jan 31 '07 #1
2 13145
On Jan 31, 4:49 am, "antonyliu2...@yahoo.com"
<antonyliu2...@yahoo.comwrote:
I've been googling for some time, and could not find the solution to
this problem.

I am testing the paging feature of gridview. I have a very simple web
form on which the user can select a few fields to be included in the
table, which is to be bound to the gridview.

The web form looks like so (Don't worry about the stupidity of this
web form for now.):

Check stuffs you wanna include in the table:

[] Customer ID
[] Customer Last Name
[] Customer First Name
[] Customer Email
[] Customer Phone

[Click this button to show the table]

[---- the paging-enabled gridview is right here ------]

The gridview is declared like so:

<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>

In the code-behind (in C#), I pass the programmatically created SQL
select command to the SqlDataSource like so:

SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;

Now, after the user clicks the button to create the customer report,
the gridview is populated with customer data with the expected fields.

But, when the paging index is clicked, the gridview disaapears. One
short note from a blog says that gridview will disappear between
postbacks. So, this might be the cause.

I guess I don't need to implement a GridView1_OnPageIndexChanging
method to handle the paging event since I don't think I am manually
binding the gridview to the dataset.

How do we handle this problem? Thanks.
sound's like you don't bind your grid after postback

Can you please tell us where you do bind it (sample code)?

Jan 31 '07 #2
On Jan 31, 1:36 am, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Jan 31, 4:49 am, "antonyliu2...@yahoo.com">

<antonyliu2...@yahoo.comwrote:
I've been googling for some time, and could not find the solution to
this problem.
I am testing the paging feature of gridview. I have a very simple web
form on which the user can select a few fields to be included in the
table, which is to be bound to the gridview.
The web form looks like so (Don't worry about the stupidity of this
web form for now.):
Check stuffs you wanna include in the table:
[] Customer ID
[] Customer Last Name
[] Customer First Name
[] Customer Email
[] Customer Phone
[Click this button to show the table]
[---- the paging-enabled gridview is right here ------]
The gridview is declared like so:
<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>
In the code-behind (in C#), I pass the programmatically created SQL
select command to the SqlDataSource like so:
SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;
Now, after the user clicks the button to create the customer report,
the gridview is populated with customer data with the expected fields.
But, when the paging index is clicked, the gridview disaapears. One
short note from a blog says that gridview will disappear between
postbacks. So, this might be the cause.
I guess I don't need to implement a GridView1_OnPageIndexChanging
method to handle the paging event since I don't think I am manually
binding the gridview to the dataset.
How do we handle this problem? Thanks.

sound's like you don't bind your grid after postback

Can you please tell us where you do bind it (sample code)?- Hide quoted text -
OK, thanks a lot. I actually mentioned it in my original post. I have
a SqlDataSource control and the GridView is bound to it in the
declaration. I repeat the GridView declaration here:

<asp:GridView ID="GridView1"
EnableViewState="true"
EnableSortingAndPagingCallbacks="true"
DataSourceID="SqlDataSource1"
runat="server"
AllowPaging="True"
AllowSorting="true">
</asp:GridView>

In the code behind, the only thing I programmatically do is to assign
the select command to SqlDataSource1 like so:

SqlDataSource1.SelectCommand = theSelectCommandCreatedOnTheFly;

In other words, I don't have anything in code-behind that mannually
binds the data to the gridview, nothing in my code-behind is like
getting a DataSet, SqlDataAdapter, Fills the DataSet, DataBind the
GridView.

That's why I also mentioned that I probably don't have to implement a
method GridView1_OnPageIndexChanging since I am not manually binding
the GridView. I might be wrong, but please advise. Thanks again.

Jan 31 '07 #3

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

Similar topics

3
by: sara | last post by:
Hi all, I have a strange problem. I have a page where I am creating a recordset that can handle paging and the query for it was originally selecting from only one table. This was all working...
2
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. ...
1
by: Guoqi Zheng | last post by:
Sir, The default paging of datagrid is somehow use too much resource, so I am using Stored procedure for the paging. You can find my Stored procedure at the end of this message. It works...
6
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...
2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
0
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
5
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it...
1
by: =?Utf-8?B?TG95b2xhIHN0YWxpbg==?= | last post by:
Hi, I am using ASP.Net 2.0 version and Windows'XP OS. I am useing the Grid view control to display the user details along with the paging concept provided by the grid view control. When i...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.