count rows in dataset...

Discussion in 'ASP .Net' started by Chris Wilmot, Jul 23, 2003.

  1. Chris Wilmot

    Chris Wilmot Guest

    Try

    MyDataset.Tables(0).Rows.Count

    Chris Wilmot
    "John Pether" <john@<nospam>dotnetsites.net> wrote in message
    news:ORC$...

    > I have the following code which loads a dataset into a datagrid:
    > <code>
    > ' Obtain Link information from Links table
    > ' and bind to the datagrid control
    >
    > Dim links As New DNSite.LinksIndexDB()
    >
    > ' DataBind Links to DataGrid Control
    >
    > DG.DataSource = links.GetLinks(CatID)
    > DG.DataBind()
    > DLLegend.DataSource = links.GetGroups
    > DLLegend.DataBind()
    > TotalLinks =
    > </code>
    >
    > TotalLinks needs to be the number of rows of data from the dataset

    links.GetLinks
    >
    > Can anyone tell me how I access that info?
    >
    > thx:)
    >
    >
    > **********************************************************************
    > Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    > Comprehensive, categorised, searchable collection of links to ASP &

    ASP.NET resources...
    Chris Wilmot, Jul 23, 2003
    #1
    1. Advertising

  2. I have the following code which loads a dataset into a datagrid:
    <code>
    ' Obtain Link information from Links table
    ' and bind to the datagrid control

    Dim links As New DNSite.LinksIndexDB()

    ' DataBind Links to DataGrid Control

    DG.DataSource = links.GetLinks(CatID)
    DG.DataBind()
    DLLegend.DataSource = links.GetGroups
    DLLegend.DataBind()
    TotalLinks =
    </code>

    TotalLinks needs to be the number of rows of data from the dataset links.GetLinks

    Can anyone tell me how I access that info?

    thx:)


    **********************************************************************
    Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    John Pether (john@, Jul 24, 2003
    #2
    1. Advertising

  3. Chris Wilmot

    Saravana Guest

    Before binding your datasource with datagrid, load it in local dataset and
    then find out the count. For example,

    Dataset1 = links.GetLinks(CatID)
    Dataset1.tables(0).rows.count
    DG.DataSource= DataSet1



    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "John Pether" <john@<nospam>dotnetsites.net> wrote in message
    news:ORC$...
    > I have the following code which loads a dataset into a datagrid:
    > <code>
    > ' Obtain Link information from Links table
    > ' and bind to the datagrid control
    >
    > Dim links As New DNSite.LinksIndexDB()
    >
    > ' DataBind Links to DataGrid Control
    >
    > DG.DataSource = links.GetLinks(CatID)
    > DG.DataBind()
    > DLLegend.DataSource = links.GetGroups
    > DLLegend.DataBind()
    > TotalLinks =
    > </code>
    >
    > TotalLinks needs to be the number of rows of data from the dataset

    links.GetLinks
    >
    > Can anyone tell me how I access that info?
    >
    > thx:)
    >
    >
    > **********************************************************************
    > Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    > Comprehensive, categorised, searchable collection of links to ASP &

    ASP.NET resources...
    Saravana, Jul 24, 2003
    #3
  4. ok, so i wasn't able to do that in the code behind but I can do it in the function from the data access class file, see code below
    So I have created a Dim TotalLinks and filled it but how do I access that from my page behind code??? any ideas?

    <code>
    Public Function GetLinks(ByVal CatID As Long) As DataSet
    Dim myConnection As New SqlConnection(strConnection)
    ' Create Instance of Connection and Command Object
    Dim myCommand As New SqlCommand("GetLinks", myConnection)

    ' Mark the Command as a SPROC
    myCommand.CommandType = CommandType.StoredProcedure

    ' Add Parameters to SPROC

    Dim parameterCatID As New SqlParameter("@CatID", SqlDbType.BigInt)
    parameterCatID.Value = CatID
    myCommand.Parameters.Add(parameterCatID)

    '********ADDED*********
    Dim TotalLinks As Long
    TotalLinks = GetLinks.Tables(0).Rows.Count
    '********ADDED*********

    ' Execute the command
    myConnection.Open()
    myCommand.ExecuteNonQuery()
    myConnection.Close()

    End Function

    **********************************************************************
    Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    John Pether (john@, Jul 24, 2003
    #4
    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. Pikarde
    Replies:
    2
    Views:
    1,045
    Danny Bloodworth
    Nov 24, 2003
  2. thomson
    Replies:
    1
    Views:
    783
    Brock Allen
    Jun 11, 2005
  3. MC
    Replies:
    2
    Views:
    8,241
  4. Martin Joergensen
    Replies:
    68
    Views:
    1,680
    Dave Thompson
    Apr 3, 2006
  5. efelnavarro09
    Replies:
    2
    Views:
    909
    efelnavarro09
    Jan 26, 2011
Loading...

Share This Page