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
320
Issues assigning cell cssclass on rowinit event
posted

I have a WHDG that I want users to be able to toggle a Boolean value for. Since I was unable to figure out how to retrieve a value from a asp checkbox inside a templated column on postback. I decided I would just display and image of a checkbox with a hidden field that held the initial value. So to display that image I used the below code to set the css class for the cell.

 

        protected void Report_Grid_InitializeRow1(object sender, RowEventArgs e)
        {
            if ((bool)e.Row.Items[0].Value)
                e.Row.Items[1].CssClass = "checkon";
            else
                e.Row.Items[1].CssClass = "checkoff";
        }

 

However when the page loads no cssclass values is set for the <td> tag of the field. But when I do any postback, even when changing the data that is bound, the <td> show up with the cssclass property set, and the background image I have shows up.

 

How can I make the WHDG process the cssclass assignments on first load? Alternately is their a better way in which to allow users to toggle a Boolean value and get the value it was set to?

  • 320
    Verified Answer
    posted

    Solved my issue:

    Infragistics does not parse the cssclass of each cell when generating the html if the ItemCssClass for the Grid is not set. I simply added ItemCssClass=" " in the properties of the WHDG and now all my cells print the cssclass that i set them to during the Row Init.