Issue with embedded datagrid.

Discussion in 'ASP .Net Web Controls' started by ylockhead, Oct 19, 2005.

  1. ylockhead

    ylockhead Guest

    I have a couple of problems with a datagrid (dgDetail) that is embedded on
    another detagrid(dgMaster). On dgDetail, I have a dropdown listbox
    (ddlbDecision) that I am trying populate. I put code in
    dgDetail_ItemDataBound to populate the listboxt but it's not working.

    My first problem is that the event dgDetail_ItemDataBound doens't get fired
    automatically when dgDetail.DataBind() is executed. To get around this, I
    trigger the event using dgdAddTimeRep_ItemDataBound(sender, e). Shouldn't
    this event work automatically?

    My second problem is how to reference the listbox ddlbDecision on dgDetail.
    I have tried referecing the control using the following code but it doens't
    work.
    Dim ddlbDecision As System.Web.UI.WebControls.DropDownList =
    CType(e.Item.FindControl("ddlbDecision "),
    System.Web.UI.WebControls.DropDownList)

    How can I reference the control ddlbDecision on the embedded datagrid so I
    can populate it??

    Thanks for your help.
    ylockhead, Oct 19, 2005
    #1
    1. Advertising

  2. The detail grid databind would fire by default before the parent control
    databind therefore it seemed to you that ItemDataBound for the detail was not
    fired because there was no data yet for the datasource of the detail when its
    datagrid_databind event was handled. To verify that this is the case place
    an If statement within your dgDetail_ItemDataBound to check if
    e.Item.dataItem is Nothing.

    You can explicity execute the detail grid databind method after you have
    retrieved the detail data during the ItemDataBound event handling in the
    master grid.

    The command you used to find the dropdownlist is correct. But if you
    attempted to use it when your datagrid binding happened on an empty
    datasource that might explain you could not find the dropdownlist.

    For a demo of what I just wrote above you may review this sample:
    http://www.societopia.net/samples/DataGrid_Hierarchy.aspx

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "ylockhead" wrote:

    > I have a couple of problems with a datagrid (dgDetail) that is embedded on
    > another detagrid(dgMaster). On dgDetail, I have a dropdown listbox
    > (ddlbDecision) that I am trying populate. I put code in
    > dgDetail_ItemDataBound to populate the listboxt but it's not working.
    >
    > My first problem is that the event dgDetail_ItemDataBound doens't get fired
    > automatically when dgDetail.DataBind() is executed. To get around this, I
    > trigger the event using dgdAddTimeRep_ItemDataBound(sender, e). Shouldn't
    > this event work automatically?
    >
    > My second problem is how to reference the listbox ddlbDecision on dgDetail.
    > I have tried referecing the control using the following code but it doens't
    > work.
    > Dim ddlbDecision As System.Web.UI.WebControls.DropDownList =
    > CType(e.Item.FindControl("ddlbDecision "),
    > System.Web.UI.WebControls.DropDownList)
    >
    > How can I reference the control ddlbDecision on the embedded datagrid so I
    > can populate it??
    >
    > Thanks for your help.
    Phillip Williams, Oct 19, 2005
    #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. Rick Wez
    Replies:
    0
    Views:
    551
    Rick Wez
    Mar 17, 2006
  2. Colin Paul Gloster
    Replies:
    48
    Views:
    1,879
    Colin Paul Gloster
    Apr 10, 2007
  3. Thomas Dodds

    Databind an embedded control in an embedded datagrid

    Thomas Dodds, Jul 26, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    398
    Thomas Dodds
    Jul 26, 2004
  4. Trans
    Replies:
    11
    Views:
    297
    micathom
    Sep 5, 2007
  5. Num GG
    Replies:
    2
    Views:
    352
    Num GG
    Nov 17, 2008
Loading...

Share This Page