We are using infragistics Ultrawebgird ver 8.2. We have image buttons that have to be enabled or disabled based on a condition written in the InitializeRow event of the ultrawebgrid. The button gets diabled while loading for the first time , but when any other event happens in the grid , the image button gets enabled automatically , where it actually has to be in disabled mode.
Solution Required : We need some code sample to maintain the Button in disabled mode between postbacks, and enable the button only when the condition is satisfied.
Thanks & Regards
ZSLINC.
I'm sure there's a better way, but a brute-force approach would be to rebind the grid on every postback, thus re-firing InitializeRow.
Another brute-force approach would be to loop through all the rows in some other event, like the grid's PreRender event.
An ImageButton can only be in a cell if it's in a templated column. By default, items put in a templated column are not kept in ViewState, which I suspect is probably the cause of your actual problem; they're recreated every postback. I know that it's possible to define a dynamic templated-column template, which you can modify to ensure that items inside the templated column are stored in ViewState, but this is a lot of work for little reward.
Creating a dynamic templated-column template is provided in the following article from our online Knowledge Base; information on ensuring the contents are stored in ViewState are also here. Note that there's a lot going on in these samples.HOWTO:Advanced Dynamic Templated Column
If you're already using dynamic templated-column templates, then adding the part to store the items in ViewState is probably worth it. Otherwise, either rebinding on every postback or looping through all the rows is probably a more efficient, if less elegant, solution.