VJs Tip Of The Day
Reply
![]() |
|
From:
![]() VishalRJoshi
|
Pagination in ASP.Net DataGrid
Quick steps to work out pagination in your datagrid.. Go to your data grid properties... Set AllowPaging property to true... Set the PageSize to your desired page size... Now go to events section in the properties... You have to override PageIndexChanged Event... In the event handler... Write code similar to the one below:
private void dgdImages_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e) { //Change the current page index to the new one dgdImages.CurrentPageIndex = e.NewPageIndex; //Update your data if required dgdImages.DataSource = CreateDataSource(); //bind the data again dgdImages.DataBind(); }
That's it... Your datagrid does not need to make your page long scrollable now... Do note though that if you change the data in the background and the new data does not contain as many pages as your current page index now you might land up getting exceptions... So make sure that you do the necessary work there...
Vishal Joshi Microsoft MVP Net If You Think YOU CAN... You Can... http://VishalJoshi.Blogspot.com http://www.microsoft.com/india/mvp/indiamvp.aspx http://groups.msn.com/ChennaiNetUserGroup http://groups.msn.com/CNUG-DAM http://groups.msn.com/NetBloomingtonUserGroup
PS: I was driving my car today, trying to rush home from work, had to do some groceries and go to library to return books and read a martin fowler's new design pattern discussion and cook and have dinner and then go to photocopy some legal documents... Oh!! I felt... 24 hours are just not enough sometime... Then I saw a guy casually walking his dog and listening to his discman... I passed by and then pulled over... Thought for while...where was I actually going wrong, why was his life so different and nicer than mine... Why life has to be unjust, just to me.. And you know what I did next... Drove to Starbucks coffee house... Took a nice tall mocha and spent 30 minutes thinking of my own design pattern... I am paying $2 fine on the library books now and I spent $5 extra at the coffee house but then Ahh!! what a realization... My life was not much different than his, it was just in the way I looked at it...
|
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|
- Re: VJs Tip Of The Day VishalRJoshi
-