2012-08-31 29 views
0

如何在頁腳的gridview中獲得總記錄數我有來源,但它沒有顯示我正確的記錄沒有。它顯示一切正確。只是總記錄沒有顯示正確的Get GridView Pager中的記錄總數

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

buttompager顯示與否? –

+0

可能的重複http://stackoverflow.com/questions/5788329/count-total-rows-of-gridview-with-pagination – yogi

+0

是顯示,但它沒有顯示正確的總記錄值。休息它顯示正確。 – Moiz

回答

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等

+0

這是什麼_totalrowscount?哪個變量? – Moiz

+0

@moiz kachwala:剛剛更改了數據集/數據錶行中的行數no – Nag

+0

是否已經測試過這些代碼?因爲它不工作。你有代碼與gridview? – Moiz