How do I find the number of rows returned in an Object Data Source

Last post 06-11-2007 5:02 AM by swaino. 6 replies.

Sort Posts:

  • How do I find the number of rows returned in an Object Data Source

    06-04-2007, 9:51 AM
    • Member
      198 point Member
    • swaino
    • Member since 10-10-2006, 11:58 AM
    • Posts 535

    Hi,

    Does anyone know how to find out how many rows have been returned when an Object Data Source has been bound?

    Thanks.


     

  • Re: How do I find the number of rows returned in an Object Data Source

    06-04-2007, 10:20 AM
    • Contributor
      2,560 point Contributor
    • Sohnee
    • Member since 02-02-2007, 10:18 PM
    • UK
    • Posts 492

    I believe you'd use the selecting event handler - like this:

        protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            bGetSelectCount = e.ExecutingSelectCount;
        }

  • Re: How do I find the number of rows returned in an Object Data Source

    06-04-2007, 10:26 AM
    • Member
      17 point Member
    • kennyp
    • Member since 06-04-2007, 10:57 AM
    • Posts 18

    Take a look at parameter 'e' in the Selected event of the ObjectDataSource. The ReturnValue should give you the datatable/dataset you're about to bind. You should be able to get the number of rows from that.

  • Re: How do I find the number of rows returned in an Object Data Source

    06-04-2007, 11:58 AM
    • Member
      198 point Member
    • swaino
    • Member since 10-10-2006, 11:58 AM
    • Posts 535

    The e.ExecutingSelectCount returns a boolean.  How would I return the number of rows from that?

  • Re: How do I find the number of rows returned in an Object Data Source

    06-05-2007, 4:18 AM
    • Member
      17 point Member
    • kennyp
    • Member since 06-04-2007, 10:57 AM
    • Posts 18

    swaino, i get the number of rows like this.

    Private Sub ObjectDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) Handles ObjectDataSource1.Selected

    NumberOfRows = e.ReturnValue.Rows.Count()

    End Sub

     

  • Re: How do I find the number of rows returned in an Object Data Source

    06-05-2007, 8:32 AM
    Answer
    • Contributor
      2,560 point Contributor
    • Sohnee
    • Member since 02-02-2007, 10:18 PM
    • UK
    • Posts 492

    Apologies - I omitted a chunk from that...

     

        bool bGetSelectCount;
        protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (bGetSelectCount)
                TextBox1.Text = e.ReturnValue.ToString(); 
        }

        protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            bGetSelectCount = e.ExecutingSelectCount;
        }

  • Re: How do I find the number of rows returned in an Object Data Source

    06-11-2007, 5:02 AM
    • Member
      198 point Member
    • swaino
    • Member since 10-10-2006, 11:58 AM
    • Posts 535

     Ok thanks all!Big Smile

Page 1 of 1 (7 items)