获取Gridview寻呼机中的总记录数

时间:2012-08-31 05:59:47

标签: asp.net c#-4.0 gridview

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

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

1 个答案:

答案 0 :(得分: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等。