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
570
Different formatting by row
posted

Is there anyway to handle different formatting for the same columns by row?

For example, the first row, I'd like to format all the numbers by percentage, and all subsequent rows format using currency.  Do you suggest using javascript to handle the format individually or I even thought of combining 2 datagrids that look like 1.  I'd prefer to control this through some sort of server-side event.  Any thoughts, advice would be greatly welcome.

Parents
  • 28464
    posted

    Hello,

    It is possible by using the InitializeRow event. Just hook the event and modify the Items collection of the row currently initialized. Items collection is zero based.

    In the example below, the second column of all even rows will be set to "1"

    protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
        {
            if (e.Row.Index % 2 == 0)
            {
                e.Row.Items[1].Text = "1";
            }
        }

    You can use String.Format and the built-in .NET formating features to format the respective cells to anything you wish.

Reply Children