sk1922
asked on
FindControl Help! ddl inside usercontrol from another control using formview control
Hello EE!
I think I'm close to getting what I need but my code bombs and I believe my formview code is to blame and how I'm trying to locate the control I need. On my page (lets call it page.aspx) I have two web user controls (lets call them jc.ascx and ec.ascx). In jc.ascx I have a formview control which has a _ModeChanging event. In this event I am trying to get a hold of a dropdownlist control which resides in my ec.ascx which is on the same page. However, I don't think I'm using findcontrol right to navigate to the control.
My page.aspx control structure is as follows:
<..."ID="TabContainer1"... >
<..."ID="COSTab"...>
<..."ID="COSUpdatePanel".. .>
' This is ec.ascx
<..."ID="EmpClassChange".. .>
<..."ID="ClassControl1"... > <---- Trying to find a DDL control in here (ddl control is returned through a public function)
</... "ID="EmpClassChange"...>
' This is jc.ascx
<..."ID="JobChange"...>
<..."ID="JobControl1"...> <----- From a formview within here
</... "ID="JobChange"...>
</..."ID="COSUpdatePanel". ..>
</..."ID="COSTab"...>
</..."ID="TabContainer1".. .>
Both code attempts shown below result in a 'Object reference not set to an instance of an object.' error in my _ModeChanging event.
I thought maybe this would do it... but no luck!!
Any thoughts on what I might be doing wrong?? I appreciate the assistance in advance.
Thanks,
sk1922
I think I'm close to getting what I need but my code bombs and I believe my formview code is to blame and how I'm trying to locate the control I need. On my page (lets call it page.aspx) I have two web user controls (lets call them jc.ascx and ec.ascx). In jc.ascx I have a formview control which has a _ModeChanging event. In this event I am trying to get a hold of a dropdownlist control which resides in my ec.ascx which is on the same page. However, I don't think I'm using findcontrol right to navigate to the control.
My page.aspx control structure is as follows:
<..."ID="TabContainer1"...
<..."ID="COSTab"...>
<..."ID="COSUpdatePanel"..
' This is ec.ascx
<..."ID="EmpClassChange"..
<..."ID="ClassControl1"...
</... "ID="EmpClassChange"...>
' This is jc.ascx
<..."ID="JobChange"...>
<..."ID="JobControl1"...> <----- From a formview within here
</... "ID="JobChange"...>
</..."ID="COSUpdatePanel".
</..."ID="COSTab"...>
</..."ID="TabContainer1"..
Both code attempts shown below result in a 'Object reference not set to an instance of an object.' error in my _ModeChanging event.
I thought maybe this would do it... but no luck!!
Any thoughts on what I might be doing wrong?? I appreciate the assistance in advance.
Thanks,
sk1922
'1st code attempt
Dim tbContainer As AjaxControlToolkit.TabContainer = DirectCast(Parent.FindControl("TabContainer1"), AjaxControlToolkit.TabContainer)
Dim pnl As Panel = DirectCast(tbContainer.FindControl("COS").FindControl("COSUpdatePanel").FindControl("EmpClassChange"), Panel)
Dim ddl As DropDownList = CType(pnl.FindControl("ClassControl1"), modules_ClassControl).GetEmpClassDDL
ddl.Enabled = False
'2nd code attempt
'Dim ddl As DropDownList = CType(CType(Parent.FindControl("TabContainer1").FindControl("COS").FindControl("COSUpdatePanel").FindControl("EmpClassChange"), Panel).FindControl("ClassControl1"), modules_ClassControl).GetEmpClassDDL
'ddl.Enabled = False
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay in getting back on this. That worked well for me!!
Thanks!
Thanks!
Dim ddl As DropDownList = CType(FindControlRecursive