Number of rows in a datagrid

Discussion in 'ASP .Net Datagrid Control' started by PaulNaude, Oct 12, 2005.

  1. PaulNaude

    PaulNaude Guest

    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!
    PaulNaude, Oct 12, 2005
    #1
    1. Advertising

  2. PaulNaude

    Scott M. Guest

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


    "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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!

    >
    >
    Scott M., Oct 12, 2005
    #2
    1. Advertising

  3. PaulNaude

    PaulNaude Guest

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

    "Scott M." wrote:

    > What about using the table's defaultView.Rows.Count?
    >
    >
    > "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > >> 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!

    > >
    > >

    >
    >
    >
    PaulNaude, Oct 14, 2005
    #3
  4. PaulNaude

    PaulNaude Guest

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

    "Scott M." wrote:

    > What about using the table's defaultView.Rows.Count?
    >
    >
    > "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > >> 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!

    > >
    > >

    >
    >
    >
    PaulNaude, Oct 14, 2005
    #4
  5. PaulNaude

    Scott M. Guest

    HTH :)


    "PaulNaude" <> wrote in message
    news:...
    > BUT, I found ...defaultview.count which does exaclty that!!! Thanks for
    > the
    > idea!
    >
    > "Scott M." wrote:
    >
    >> What about using the table's defaultView.Rows.Count?
    >>
    >>
    >> "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
    >> news:...
    >> > 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" <> wrote in message
    >> > news:...
    >> >> 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!
    >> >
    >> >

    >>
    >>
    >>
    Scott M., Oct 16, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,226
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. helpful sql
    Replies:
    0
    Views:
    807
    helpful sql
    May 19, 2005
  3. lalitha1024
    Replies:
    1
    Views:
    812
    =?Utf-8?B?SmFjZWsgU3Rhd2lja2k=?=
    Jul 19, 2005
  4. Arjen Hoekstra
    Replies:
    0
    Views:
    550
    Arjen Hoekstra
    Aug 2, 2005
  5. Jason James

    Rows the rows of a grid view?

    Jason James, Aug 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    393
    Jason James
    Aug 10, 2006
Loading...

Share This Page