0

如何获取gridview页脚的记录总数。我有来源,但没有显示正确的记录。它显示其他一切都是正确的。只是总记录显示不正确

<PagerTemplate>
    Showing
    <%= grdProductStock.PageIndex * grdProductStock.PageSize + 1%>
      to
   <%= grdProductStock.PageIndex * grdProductStock.PageSize + grdProductStock.Rows.Count%>
      of
   <%= grdProductStock.PageCount * grdProductStock.Rows.Count%>
      Records
 </PagerTemplate>
4

1 回答 1

0

试试这个,我很久以前在谷歌搜索时发现了它。

protected void grdProductStock_DataBound(object sender, EventArgs e) {
    if (grdProductStock!= null)
    {
        //Showing Search Result Count
        //Get Top Pager Row from a gridview
        GridViewRow row = grdProductStock.TopPagerRow;
        if (row != null)
        {
            //Create one Cell for adding in my current paging strip
            TableCell infocell = new TableCell();
            infocell.Text = ” Page ” + (grdProductStock.PageIndex + 1).ToString() + ” of ” +grdProductStock.PageCount.ToString() +“(” + table.Rows.Count.ToString() + ” Records)”;

            //Getting table which shows PagingStrip
            Table tbl = (Table)row.Cells[0].Controls[0];

            //Will Find  table
            tbl.Rows[0].Cells.Add(infocell);
        }
    }
}

这里的表是您的数据源,即 dataset.tables[0].rows.count。datatable.rows.count 等

于 2012-08-31T06:29:23.043 回答