Two-part Question: Refresh DetailsView and Disabling a TemplateField Control

Two-part Question: Refresh DetailsView and Disabling a TemplateField Control

Old forum URL: forums.lhotka.net/forums/t/2259.aspx


DougZ posted on Thursday, February 01, 2007

I have a DetailsView control on a web form that uses a CslaDataSource control.  The DetailsView has two DropDownList controls in it.  Selecting an item in RecruitingPeriodDropDownList is required to save the object, while selecting an item in EventVisitDropDownList is optional.  However, selecting an item in EventVisitDropDownList determines which value should be selected in RecruitingPeriodDropDownList.  The business object underlying the DetailsView control takes care of setting the value of the RecruitingPeriodId property when the EventVisitId property is set, but RecruitingPeriodDropDownList is not updated to show that value. 

It seems that there are two versions of the business object:  one in the CslaDataSource and one stored in Session.  When the data source's UpdateObject event is fired, the code in the event handler maps the data from the bo in CslaDataSource to the bo in the Session.  So, the form doesn't display the change made to the RecruitingPeriodId property until the UpdateObject event is fired.  How do I update the bo in Session to reflect what is in CslaDataSource prior to that event firing?

Next question ...

The aforementioned DropDownList controls are in TemplateFields in the DetailsView control.  If an item is selected in EventVisitDropDownList, I want to disable RecruitingPeriodDropDownList.  However, I can't find out how to reference those controls in the server-side code.  Do I have to script it?

Thanks,
Doug



DougZ replied on Friday, February 02, 2007

I found the answer to my second question.  When referencing controls that are housed inside data-bound controls such as the DetailsView control, you can use the DetailsView.FindControl() method to get a reference to the control and assign it to a variable.  Then, you can manipulate the control's properties.

I'm still working on my first question.  I am guessing that it involves using the DataMapper, but I'm not sure how to do that outside of a CslaDataSource event.  Any ideas?

Thanks,
Doug

Copyright (c) Marimer LLC