Number of rows in a datagrid

P

PaulNaude

I discovered the hard way that the property "VisibleRowCount" of a datagrid
is ONLY that, the number of visible rows, NOT the number of populated rows in
the datagrid.

I need the number of populated rows (i.e. the number of records the user has
access to by scrolling to the end of the list).

I can't get it from the table since the datagrid is filtered.

Should I actually run a for next loop to count the rows, or even create a
datatable from the datagrid?

I am sure there must be a short cut!
 
S

Scott M.

What about using the table's defaultView.Rows.Count?


Alvin Bruney - ASP.NET MVP said:
nope either loop or use the dataset.tables.rows.count. if it is filtered
like you say, you can still get the sum of the filtered row by passing in
the filter to the dataset and a count expression. there's more help on
this
topic on MSDN and code snippets to do it as well.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



PaulNaude said:
I discovered the hard way that the property "VisibleRowCount" of a datagrid
is ONLY that, the number of visible rows, NOT the number of populated
rows in
the datagrid.

I need the number of populated rows (i.e. the number of records the user has
access to by scrolling to the end of the list).

I can't get it from the table since the datagrid is filtered.

Should I actually run a for next loop to count the rows, or even create a
datatable from the datagrid?

I am sure there must be a short cut!
 
P

PaulNaude

Unfortunaterly, Rows is not a member of defaultview. That should have been
ideal!

Scott M. said:
What about using the table's defaultView.Rows.Count?


Alvin Bruney - ASP.NET MVP said:
nope either loop or use the dataset.tables.rows.count. if it is filtered
like you say, you can still get the sum of the filtered row by passing in
the filter to the dataset and a count expression. there's more help on
this
topic on MSDN and code snippets to do it as well.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



PaulNaude said:
I discovered the hard way that the property "VisibleRowCount" of a datagrid
is ONLY that, the number of visible rows, NOT the number of populated
rows in
the datagrid.

I need the number of populated rows (i.e. the number of records the user has
access to by scrolling to the end of the list).

I can't get it from the table since the datagrid is filtered.

Should I actually run a for next loop to count the rows, or even create a
datatable from the datagrid?

I am sure there must be a short cut!
 
P

PaulNaude

BUT, I found ...defaultview.count which does exaclty that!!! Thanks for the
idea!

Scott M. said:
What about using the table's defaultView.Rows.Count?


Alvin Bruney - ASP.NET MVP said:
nope either loop or use the dataset.tables.rows.count. if it is filtered
like you say, you can still get the sum of the filtered row by passing in
the filter to the dataset and a count expression. there's more help on
this
topic on MSDN and code snippets to do it as well.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



PaulNaude said:
I discovered the hard way that the property "VisibleRowCount" of a datagrid
is ONLY that, the number of visible rows, NOT the number of populated
rows in
the datagrid.

I need the number of populated rows (i.e. the number of records the user has
access to by scrolling to the end of the list).

I can't get it from the table since the datagrid is filtered.

Should I actually run a for next loop to count the rows, or even create a
datatable from the datagrid?

I am sure there must be a short cut!
 
S

Scott M.

HTH :)


PaulNaude said:
BUT, I found ...defaultview.count which does exaclty that!!! Thanks for
the
idea!

Scott M. said:
What about using the table's defaultView.Rows.Count?


Alvin Bruney - ASP.NET MVP said:
nope either loop or use the dataset.tables.rows.count. if it is
filtered
like you say, you can still get the sum of the filtered row by passing
in
the filter to the dataset and a count expression. there's more help on
this
topic on MSDN and code snippets to do it as well.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



I discovered the hard way that the property "VisibleRowCount" of a
datagrid
is ONLY that, the number of visible rows, NOT the number of populated
rows
in
the datagrid.

I need the number of populated rows (i.e. the number of records the
user
has
access to by scrolling to the end of the list).

I can't get it from the table since the datagrid is filtered.

Should I actually run a for next loop to count the rows, or even
create a
datatable from the datagrid?

I am sure there must be a short cut!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top