Nested Gridviews

Discussion in 'ASP .Net' started by Chris, Apr 1, 2007.

  1. Chris

    Chris Guest

    I am creating a nested gridview as per the tutorial here
    (http://msdn2.microsoft.com/en-us/library/aa992038(vs.80).aspx). My
    gridviews work fine. I have a master gridview containing the customerid.
    This value is used by a a detail gridview nested within the master. This
    works well but when I hide the customerid the filter stops working. I
    suspect that this code can't find the ID to do the filtering. How do get
    around this as I want to hide the CustomerID. Also how efficient is this?
    Does it involve a separate call to the database for each row in the parent.
    Is it possible grab all the child detail data in one go and filter via a
    dataview. I quite like using typed datasets and the objectdatasource but I
    don't want ineffiicient code. Regards, Chris.

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    GridView1.RowDataBound

    If e.Row.RowType = DataControlRowType.DataRow Then

    Dim o As ObjectDataSource = CType(e.Row.FindControl("objdsgetorders"),
    ObjectDataSource)

    o.SelectParameters(0).DefaultValue = e.Row.Cells(0).Text

    End If

    End Sub
    Chris, Apr 1, 2007
    #1
    1. Advertising

  2. Chris

    Chris Guest

    I found another way but if anyone has any opinions on the other questions
    they would be welcome.

    o.SelectParameters(0).DefaultValue =
    GridView1.DataKeys(e.Row.DataItemIndex).Value



    "Chris" <> wrote in message
    news:...
    >I am creating a nested gridview as per the tutorial here
    >(http://msdn2.microsoft.com/en-us/library/aa992038(vs.80).aspx). My
    >gridviews work fine. I have a master gridview containing the customerid.
    >This value is used by a a detail gridview nested within the master. This
    >works well but when I hide the customerid the filter stops working. I
    >suspect that this code can't find the ID to do the filtering. How do get
    >around this as I want to hide the CustomerID. Also how efficient is this?
    >Does it involve a separate call to the database for each row in the parent.
    >Is it possible grab all the child detail data in one go and filter via a
    >dataview. I quite like using typed datasets and the objectdatasource but I
    >don't want ineffiicient code. Regards, Chris.
    >
    > Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    > GridView1.RowDataBound
    >
    > If e.Row.RowType = DataControlRowType.DataRow Then
    >
    > Dim o As ObjectDataSource = CType(e.Row.FindControl("objdsgetorders"),
    > ObjectDataSource)
    >
    > o.SelectParameters(0).DefaultValue = e.Row.Cells(0).Text
    >
    > End If
    >
    > End Sub
    >
    >
    >
    >
    Chris, Apr 1, 2007
    #2
    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. Replies:
    0
    Views:
    4,773
  2. Roy
    Replies:
    1
    Views:
    3,815
  3. Mr Nobody

    Nested GridViews In UserControls.

    Mr Nobody, Jul 25, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    314
    Lucas Hernandez
    Jul 25, 2008
  4. katmagic

    Gridviews and Nested Gridview

    katmagic, Jan 17, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    323
    katmagic
    Jan 17, 2009
  5. JohnE

    multiple nested gridviews

    JohnE, Mar 23, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    1,160
    JohnE
    Mar 23, 2010
Loading...

Share This Page