Hi All,
I am binding gridview dynamically and when i try for paging I am not able to even see the paging on the page.My coding is as below.Please
suggest what I am misssing.I am binding Gridview in Page_Init event.paging is not showing at all with gridview.what could be the reason.I am using pageindexchanging event also but still I am not able
to see paging on the page.I am binding all times.I need the Gridview to be created dynamically so I am writing code behind
workGrid.RowEditing += new GridViewEditEventHandler(workGrid_RowEditing);
workGrid.RowDeleting += new GridViewDeleteEventHandler(workGrid_RowDeleting);
workGrid.RowDataBound += new GridViewRowEventHandler(workGrid_RowDataBound);
TemplateField BtnTmpField = new TemplateField(); BtnTmpField.ItemTemplate = new GridViewTemplate(ListItemType.Item, "Modify", "Command");
BtnTmpField.HeaderTemplate = new GridViewTemplate(ListItemType.Header, "Modify", "Command"); BtnTmpField.EditItemTemplate = new GridViewTemplate(ListItemType.EditItem, "...", "Command"); workGrid.Columns.Clear();
workGrid.Columns.Add(BtnTmpField);
for (int workCnt = 0; workCnt < dtWorksGrid.Columns.Count; workCnt++)
{ TemplateField ItemTmpField = new TemplateField();
ItemTmpField.HeaderTemplate = new GridViewTemplate(ListItemType.Header, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
ItemTmpField.HeaderStyle.Width = Unit.Pixel(145);
ItemTmpField.ItemTemplate = new GridViewTemplate(ListItemType.Item, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
ItemTmpField.EditItemTemplate = new GridViewTemplate(ListItemType.EditItem, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
workGrid.Columns.Add(ItemTmpField);
}
workGrid.DataSource = dtWorksGrid;
workGrid.DataBind();
workGrid.AllowPaging = true;
workGrid.PageSize = 5;
workGrid.PageIndexChanging += new GridViewPageEventHandler(workGrid_PageIndexChanging);
void workGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
bindWorkGrid(workType);
reg_workgrid.PageIndex = e.NewPageIndex;
reg_workgrid.DataBind();
}