Intersoft WebGrid Documentation
How-to: Change the ForeColor of all odd rows
See Also Send comments on this topic.

Glossary Item Box

In WebGrid.NET the ForeColor can be changed programmatically in InitializeRow event handler.

In this topic, you will learn how to programmatically change the ForeColor of all odd rows in WebGrid.

To change the ForeColor of all odd rows in WebGrid

  1. Drag ASP.NET button to your WebForm.
  2. On InitializeRow event handler, put the following code:

    C# Copy ImageCopy Code
    private void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
    {
            int rowPosition = e.Row.Position;
            int rowIndexSelection = rowPosition%2;
            if(rowIndexSelection == 0)
            {
                    e.Row.Style.ForeColor = Color.Red;
            }
    }
    

  3. Compile and run the Project.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.