Issue with embedded datagrid.

Y

ylockhead

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.
 
P

Phillip Williams

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top