Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
670
BoundCheckBoxColumn and IBooleanCoverter Issue
posted

I have figured out how to setup a Class that implements IBooleanConverter before I saw this example:

http://forums.infragistics.com/forums/p/61008/309877.aspx#309877

But I was getting an error on postback about the Class not having a Default constructor.  My class does not in fact have one so the error makes sense.  However, why should this need a default constructor? 

If I do that then I have to follow the example above for EACH kind of conversion combinations that I might have for boolean conversion rather then write a class that takes a true/false value as constructor parameters to provide as the check values.  Unfortunately I have at least two or three of these conversion combinations, possibly more due to how the data was setup and what columns get shown.  Because each possible combination requires its own converter (at least using the example above), this is very inflexible and not scalable.  I created a class that can handle a comparison of what it is given for true/false check values. While similar to the example provided, it does not require hard coding creation of separate classes for each new scenario,but is more flexible and requires no additional coding for new scenarios beyond the instantiation.

When I tried to figure out where in the code to add the converter to the column, I looked at the example.  It shows the setting in the Page Load.  However the code I am running never gets to Page Load, but throws an error between Page_Init and Page_Load, at which time I do not have access to the columns of the WebDataGrid yet (columns are created dynamically in Page load on Postback). 

What do I need to do to get this to work?  Do I have to create individual classes for each type of scenario?  Do I need to set a faked out Default Constructor so that the Infragistics code is happy then once the column is created, set it again with the really convertor? Neither of these sounds like good solutions.  Is there some other way?

 

Parents
  • 33839
    posted

    Hi greghendricks,

    The reason for needing a default constructor is that we recreate the value converter using reflection on a posback.  So we cannot assume any particular type of constructor.  You should have a default one.  However, you shouldn't have to reset any properties.  If you have your class implement IStateManager, you can have it save and load its view state through the grid automatically.  You really should only need a ValueConverter if your data is not boolean; for that data we use a DefaultBooleanConverter internally.  Hopefully, this information helps.  If you're still confused, could you maybe attach what your value converter class looks like so I could help?

    regards,

    David Young

Reply Children