how to display 10 record in a page using Gridview.

Posted by Johnseelan under ASP.NET on 10/11/2012 | Points: 10 | Views : 13247 | Status : [Member] | Replies : 6
Hi All,

i have a table ,
that table have 100 record, i need to display 10 record at a time then if i click next page in my gridview that time only aonther 10 record get from table and diaplay
how to do.
if i am going it will afftect the page performance or it is the correct way to display the data.
and second doubt is:

i have a gridview,
using gridview i am doing 2 add, 2 delete and 2 update,
if i click the save button all the thing are affected in my table
how to do
please explain.




Responses

Posted by: Hemanth.Sutapalli on: 10/11/2012 [Member] Starter | Points: 25

Up
0
Down
HI johnseelan,
By using paginaton you can.
in your asp page Write This code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" PageSize="10" OnPageIndexChanging="ChangePage">

And your .cs page write this code:
protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
PopulateData();//This is your table data method
}
}
protected void ChangePage(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.PopulateData();
}


Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnseelan on: 10/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Hemanath,

thanks for ur answer,

but is is every time retrofiring all the records rit?
but i need only 10 records at time, when i click the next button that time only another 10 record will come
\

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ksuresh on: 10/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Johnseelan,

Pagination for Girdview Data http://www.dotnetfunda.com/articles/article1599-how-to-do-pagination-for-the-gridview-data-.aspx

Learn GridView related articles from http://www.dotnetfunda.com/articles/article1655-22-gridview-tips-and-tricks-by-sheo-narayan.aspx

Thanks
Suresh

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 10/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Johnseelan,
1. You are absolutely correct. If you have a lakh of records and you are using the Pagination and paging property of asp:gridview control.. It gives a lot of performance issue's coz each time ill be getting the whole table from my database and we display only the page size records.
Hence, it is a best approach to always use "Custom Pagination".

So basically, we drew the required records from the database by using Custom Pagination approach.
Refer this article, it brings you a clear picture.

http://www.dotnetfunda.com/articles/article1648-how-to-do-custom-pagination-in-the-gridview-to-achieve-better-performance-i.aspx

You can watch a video tutorial by Mr. Sheo sire here
http://www.fundoovideo.com/collection/video/gridview-tips-and-tricks-videos/10/123

2. To perform CRUD operations on gridview.
For article: http://www.dotnetfunda.com/articles/article1619-how-to-perform-edit-update-and-delete-operation-in-gridview.aspx
For Video Tutorial : http://www.fundoovideo.com/collection/video/gridview-tips-and-tricks-videos/10/131

Regards,

Awesome Coding !! :)

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/12/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi..
Refer this url u will find how to display 10 record at a time.
http://www.codeproject.com/Articles/17397/Custom-Paging-and-the-GridView-in-ASP-NET-2-0-You

.

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/12/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
@Johnseelan
Plese Mark As Answer if this helps u.

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response