hai,
I used gridview pager for page sizing. But I have more than 15 web pages that are also needed page sizing. how can i create a class for this purpose and access it.
The code I used is:
protected void GrdStudent_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
DropDownList ddl = new DropDownList();
//adds variants of pager size
ddl.Items.Add("5");
ddl.Items.Add("10");
ddl.Items.Add("15");
ddl.AutoPostBack = true;
//selects item due to the GridView current page size
ListItem li = ddl.Items.FindByText(GrdStudent.PageSize.ToString());
if (li != null)
ddl.SelectedIndex = ddl.Items.IndexOf(li);
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
//adds dropdownlist in the additional cell to the pager table
Table pagerTable = e.Row.Cells[0].Controls[0] as Table;
TableCell cell = new TableCell();
cell.Style["padding-left"] = "15px";
cell.Controls.Add(new LiteralControl("Page Size:"));
cell.Controls.Add(ddl);
pagerTable.Rows[0].Cells.Add(cell);
}
}
void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
//changes page size
GrdStudent.PageSize = int.Parse(((DropDownList)sender).SelectedValue);
//binds data source
DataTable ObjDt = ViewState["table"] as DataTable;
GrdStudent.DataSource = ObjDt;
GrdStudent.DataBind();
}
Thanks in advance,
sreevidya.