简体   繁体   中英

paging for dynamically created gridview

Hi I'm creating gridviews dynamically in Page_Init as per the received tables from the database as below , if I receive 4 tables then 4 gridviews will be generated

GridView gd = new GridView();
      gd.ID = "gdd" + i;
      gd.AllowPaging = true;
      gd.PageSize = 10;
      gd.PageIndexChanging += new GridViewPageEventHandler(GridView_PageIndexChanging);

and my question is to how to do paging for it , any help would be appreciated and how to retain the values when postback

Use this

protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvCustomers.PageIndex = e.NewPageIndex;
    PopulateCustomers();
}

For more information use Gridview paging example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM