【问题标题】:Get Total No of Records in Gridview Pager获取 Gridview 寻呼机中的总记录数
【发布时间】:2012-08-31 05:59:47
【问题描述】:

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

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

【问题讨论】:

  • 按钮页面是否显示?
  • 是的,它正在显示,但没有显示正确的总记录值。休息它显示正确。
  • @yogi:不,它不是重复的。我想按照这个代码去。我猜这个指标的计算有问题

标签: asp.net c#-4.0 gridview


【解决方案1】:

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

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 等

【讨论】:

  • 这个 _totalrowscount 是什么?哪个变量?
  • @moiz kachwala:刚刚更改了数据集/数据表行中的总行数
  • 你测试过这段代码吗?因为它不工作。你有 gridview 的代码吗?
猜你喜欢
  • 2012-09-11
  • 1970-01-01
  • 1970-01-01
  • 2022-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-31
相关资源
最近更新 更多