numbering rows in datagrid

  • Thread starter Thread starter buran
  • Start date Start date
B

buran

Dear ASP.NET Users,

How can I get the total number of rows selected by the command text of the
datagrid (items in datagrid)? If I use the statement grdSP.Items.Count with
the datagrid grdSP with paging, it returns the page size (5,10..) not the
total results. How can I get the total no?
Thanks in advance,

Buran
 
Depends. If you are using a DataSet to bind, you can do the following:

int rowCount = DataSet1.Tables[0].Rows.Count;

or VB.NET

Dim rowCount as Integer = DataSet1.Tables(0).Rows.Count

If you are using a DataReader, you have to stream through the entire reader
to get the end result. For paging and sorting, DataReaders are not the best
option overall.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top