1
Reply

Unable to access controls programmatically inside a FormView

sandeep ram

sandeep ram

Nov 26 2009 12:17 AM
5.1k
Hi,

I have this problem :

 I add two DropDownLists inside a FormView(any template - edit or insertitemtemplate). Lets call them DDL1 and DDL2.

Now DDL2 will be bound, or re-bound whenever DDL1_SelectedIndexChanged event is fired. BUT - for DDL2 to be bound, it has a ObjectDataSource whose SelectMethod is something like GetItemsById(Guid Id) where Id is the SelectedValue of DDL1.

So when I configure the select method for the ODS for DDL2, it asks me to select the source of the parameter - where I am supposed to select the DDL1...but DDL1 is not showing in the list of controls...

Since I have the same DropDownLists in both Insert and Edit ITem templates I am using only one set of ODS for both of them. So I have only two ODS for these DropDowns which will be used in both the Edit and Insert Templates.

But then there is this problem now.

However, I noticed that, if I put the ODS inside each template (so 2 each for each template) then the controls are accessible while configuring the select method. BUt this is a very expensive way since ODS is said to be  a "heavy-resource" item.

Also when I have to write code in the code behind page for this form, like when I have to write the selectedindexchanged event for one of the DDLs, I have to do a findcontrol inside the formview for the required DDL and then do a databind.

Please help.


Answers (1)