Results 1 to 9 of 9

Thread: Get # of rows in datagrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Posts
    15

    Get # of rows in datagrid

    I can't seem to find the correct property here...I have only found the DataGrid1.VisibleRowCount...I need all rows.

    Thanks,

    Sean

  2. #2
    Addicted Member ender_pete's Avatar
    Join Date
    Aug 2000
    Location
    Virginia, United States
    Posts
    131
    what are you using as a datasource? you can easily get the rowcount from the datasource.
    ender_pete
    C#,VS.NET Ent Arch, vb6 ee sp5,html,vbscript,jscript,
    xml,dhtml,delphi,c++,vc++,java,cgi,php, python, ada(so ancient) ,adasage(also ancient) and others i can't remember.....

  3. #3
    Addicted Member ender_pete's Avatar
    Join Date
    Aug 2000
    Location
    Virginia, United States
    Posts
    131
    something like this

    Code:
    Me.BindingContext(dstReturn, "order_item").Count
    dstReturn is the dataset
    order_item is the table on the dataset i want to get the rowcount from
    ender_pete
    C#,VS.NET Ent Arch, vb6 ee sp5,html,vbscript,jscript,
    xml,dhtml,delphi,c++,vc++,java,cgi,php, python, ada(so ancient) ,adasage(also ancient) and others i can't remember.....

  4. #4
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279
    I've been faced with the same problem for a little while now. I've got a web service that queries the database and pulls back a dataset. I needed to get the number of rows but could only find the visible row count property as well.
    A cynic knows the price of everything but the value of nothing.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    On the presumption that the data in the datagrid is mapped to a datable, simply code as follows:

    dim mycount as integer

    mycount = Ds1.Tables("mytable").Rows.Count

    where Ds1 is the Dataset and mytables is the mappingname of the table the datagrind is bound to

  6. #6
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279
    Thanks for the code. I did find another way to do it using the rowcount of the dataset but it takes two trips to the web service.
    A cynic knows the price of everything but the value of nothing.

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    You could obtain the number of rows when you fill the dataset

    VB Code:
    1. Dim iCount As Integer
    2.         iCount = da1.Fill(ds1, "TableName")
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125

    Question

    hi!
    hope somebody can still answer this question... what if it's related to another table? how can i count the number of rows of that table?

  9. #9
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    DataBase Password/Connection Problem

    Hi, I Have Asked Before And Still Cant Get it To Work as I Keep Getting it Underlined, Maybe a option Explicit or Strict Error. Here is a Example of how I Make My connection and Using the First, Next, Etc.

    Will Someone please Make a password for the Database called Password and Configure the Connection so it will Work. It Usually asks for Username and Password when I Only Put In A Database Password.

    Helping with the Find Button Will be A BONUS.
    The Database is in the bin Folder. Place The Zip in The C:\ And Unzip.
    Attached Files Attached Files
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width