Hi Guys,
Many times we need to create custom SpGridview control and need to add paging in such control,Here I have gone through bit of code which facilitate to add paging in SPGridview Control.
SPGridView gv = new SPGridView();
gv.AutoGenerateColumns = false;
gv.AllowPaging = true;
gv.PageSize = 10;
gv.PageIndexChanging += new GridViewPageEventHandler(gv_PageIndexChanging);
gv.PagerTemplate = null; //You must add this line before binding the DataSource.
gv.DataSource = dv;//Here dv is an object of Dataview
gv.DataBind();
Now you need to add PageIndexChanging Event.
void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gv.PageIndex = e.NewPageIndex;
gv.DataBind();
}
Hope it will help you.
Coming Soon
7 years ago
No comments:
Post a Comment