I am setting GridView's layout features in the RowDataBound event based on the content of specific cells
private void OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[1].Text == " ")
{
e.Row.Cells[4].BackColor = System.Drawing.Color.White;
e.Row.Cells[5].BackColor = System.Drawing.Color.White;
e.Row.Cells[6].BackColor = System.Drawing.Color.White;
Is there a way to specify the range (cell index 4 to 6) where this operation has to be applied to?
Something like:
private void OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[1].Text == " " && e.Row.CellIndex >= 4 && e.Row.CellIndex <= 6)
{
e.Row.BackColor = System.Drawing.Color.White;
That should be what you need:
If you really need to check if its a
DataControlRowType.DataRow, you can insert it to the if in the for loop.