AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 How to paging in gridview in asp.net
Posted by Muhammad Fahad on  2/5/2010 4:17:23 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
I have a grid and in property allow paging is true.
I am posting data from textboxes not binding data so my paging is not working at that time when i post data. I set gridview pagesize to 5.
Please tell me how paging will work at the time of posting.?

Post Your Reply Post New Question

 Viewer's Reply
Paging in GridView without Binding Data
Answered By Moderator1 on 2/6/2010 12:50:36 AM
Hi,

Without binding data you cannot make paging in GridView control. For every event you need to bind the Gridview control. As you are not taking data from database, you can save your datatable or dataset in the ViewState variable.

I mean, when you enter value in your textbox and submit, add it as a row in a DataTable, then this DataTable has to be saved as ViewState variable, then bind this DataTable with the GridView control, this will enable paging in GridView control.
 
About Binding and viewstate
Answered By Muhammad Fahad on 2/6/2010 6:34:43 AM
when i post data form textboxes to girdview after that i am binding data to gridview.
but i dont know how to save in view state plz tell me about that...
Thanx in advanced.
 
Assign DataTable to ViewState variable
Answered By Moderator1 on 2/9/2010 12:51:04 AM
Hi,

So you know how to bind data to a DataTable before bind it to GridView control. So the syntax to save DataTable to ViewState is below,

ViewState["dataTable"] = datatable;

For retrieving the value from ViewState,

DataTable datatable = (DataTable) ViewState["dataTable"];
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks - Free 158 Page Preview
Introduction to Web Applications Development
Windows 8: 50 Questions and Answers You Need to Make a Decision (Normally $9.95)