Parent/Child CC In GridView

Discussion in 'ASP .Net' started by Andrew Hayes, Dec 1, 2006.

  1. Andrew Hayes

    Andrew Hayes Guest

    I have a parent page with a gridview, and a child page with a formview.

    Using the solution on velocityreviews:

    http://www.velocityreviews.com/foru...indow-from-popup-child-window-dialog-box.html

    I was able to create the Parent and Child Window custom controls and get
    them to work correctly so that I could select a row in the GridView of the
    parent page and popup a child window with the details, and when the FormView
    was updated the GridView of the parent was refreshed without closing the
    child.

    This was by using a CommandField to perform the Select of the row, and then
    clicking on the WindowOpenButton. But I don't want the user to have to
    perform 2 clicks, so I replaced the CommandField with a TemplateField that
    included the WindowOpenButton.

    Unfortunately, while I was able to pass the DataKey to the Child form using
    a URL parameter, the SelectedIndexChanged event doesn't fire as the
    Javascript onclick event stops the custom control from processing the
    CommandName="Select".

    Any ideas on how I might solve this?

    This is, the select button for a row in the GridView changes the
    SelectedIndex *then* fires the Javascript "window.open"...

    TIA
    Andrew Hayes, Dec 1, 2006
    #1
    1. Advertising

  2. Andrew Hayes

    Andrew Hayes Guest

    The solution was to use the GridView_DataRowBind event to add a rowindex
    attribute to each WindowOpenButton with the rowindex of the GridViewRow that
    fired the event.

    This can then be retrieved during the WindowOpenButton_Click even in order
    to set the GridView.SelectedIndex.

    OK. So it's a little more complex than that. I had to remove the Javascript
    onclick code from the WindowOpenButton_OnPreRender event so that the
    WindowOpenButton_Click would actually fire, and changed the
    PostBack_WindowOpenButton() function to use the PostBackReferenceEvent for
    the Page rather than the WindowOpenButton control (otherwise every time you
    postback via the child window, another child window appears).

    But I finally got it all to work so that clicking on the Select button of a
    row in the GridView, highlights the row then opens a popup window (cannot
    use modal, of course), that shows the detail in a FormView. Clicking Update
    on the FormView updates the data and refreshes the GridView without closing
    the child window. Clicking on the Delete button on the FormView refreshes
    the GridView and closes the child window.
    Andrew Hayes, Dec 1, 2006
    #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. davout
    Replies:
    0
    Views:
    540
    davout
    Apr 18, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,084
    David Schwartz
    Dec 9, 2003
  3. crpietschmann

    Save Child GridView only when parent GridView Saved

    crpietschmann, Sep 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    574
    Steven Cheng[MSFT]
    Sep 7, 2006
  4. Noel Dolan
    Replies:
    0
    Views:
    216
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    119
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page