Conditions on the DetailsView

Posted by jpabluz on Stack Overflow See other posts from Stack Overflow or by jpabluz
Published on 2010-04-07T19:41:12Z Indexed on 2010/04/07 19:43 UTC
Read the original article Hit count: 476

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET