Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.Please suggest

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();
        // create HeaderTemplate
        ItemTmpField.HeaderTemplate = new GridViewTemplate(ListItemType.Header, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
        ItemTmpField.HeaderStyle.Width = Unit.Pixel(145);
        // create ItemTemplate
        ItemTmpField.ItemTemplate = new GridViewTemplate(ListItemType.Item, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
        //create EditItemTemplate
        ItemTmpField.EditItemTemplate = new GridViewTemplate(ListItemType.EditItem, dtWorksGrid.Columns[workCnt].ColumnName, dtWorksGrid.Columns[workCnt].DataType.Name);
        // then add to the GridView
        workGrid.Columns.Add(ItemTmpField);
    }

    workGrid.DataSource = dtWorksGrid;
    workGrid.DataBind();
    workGrid.AllowPaging = true;
    workGrid.PageSize = 5;
    workGrid.PageIndexChanging += new GridViewPageEventHandler(workGrid_PageIndexChanging);
Posted
Updated 22-Mar-10 1:55am
v3

1 solution

Have you used page index changing event...?

see this Link

regards
koolprasad2003 :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900