views:

14

answers:

0

What is the best way of implementing conditions (requiring fields based in other fields) in a DetailsView?

I have this:

protected override ICollection CreateFieldSet(object dataItem, bool useDataSource)
{
       var country = new BoundField();
       country.DataField = "Country";
       country.ReadOnly = ViewState["DifferentAddress"] != null;
}

I set the ViewState["DifferentAddress"] later, but since the change happens after the controls are created I lost the current state and get the old state.

Which is the desired way of doing this? I am in the right path - or should I use another class to do this?