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...
Mitesh Mehta
Wednesday, March 16, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment