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?
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
Thanks for the information.
I tried implementing IStateManager based on what I found on MS site.
http://msdn.microsoft.com/en-us/library/system.web.ui.istatemanager.aspx
And all appears to work on the first postback. However, on the second postback, all values have been lost. Am I missing something?
See attached sample page with the BooleanConvert class in it that implements IBooleanConverter and IStateManager.
To test,
1) I load the page (all is good).
2) I click one of the column headers to sort (and cause a postback - all is still well),
3) then I click again on the header (I chose the same header - and the errors occur - Obj. ref not set to an instance of an object).
Hello Greg,
I have created support ticket: CAS-86097-GVT213. We will continue our communication through the support ticket.
Thank you
Hi,
I was able to eventually get your sample to run and I did see it not working. For some reason, your view state is not saving correctly. You return null, so nothing is saved. My feeling is you have that set up incorrectly. I'm going to forward this along to developer support so that they can investigate for you.
David,
Have you been able to take a look at my issue?