Aspose.Grid - ASP.Net - Coloring individual cells no longer working with hotfix/update

I am using Aspose.Grid in my web application. The following code was working fine until now:

private void ColorCells(DataSet _ds)

{

WebWorksheet sheet = dg.WebWorksheets[dg.ActiveSheetIndex];

int rows = _ds.Tables[0].Rows.Count;

for (int i = 0; i < rows; i++)

{

if (_ds.Tables[0].Rows[i]["Adjustment"].ToString().ToLower() == "yes")

{

sheet.Cells[i, 8].Style.BackColor = Color.FromName("Red");

sheet.Cells[i, 8].Style.ForeColor = Color.FromName("White");

}

}

}

Now, the entire column (every row) takes on the color assignment that I set for the last row of the grid. I no longer can set cell coloring row by row.

What am I doing wrong? What can I do to change this behavior? I have installed the 10/11/2007 hotfix, no change.

Thank you for your time and attention,

Eric Christianson

Hi Eric,

What do you mean by : "Now, the entire column (every row) takes on the color assignment that I set for the last row of the grid. I no longer can set cell coloring row by row."

Which version of Aspose.Grid.Web you are using, Kindly try the latest 1.9.3 as I don't find any problem setting foreground and background color for the cells in a column.

If you still find the issue, please do create a sample test project, zip it and post it here to show the problem.

Thank you.

Hi Amjad -

I am using the latest hotfix (10/12/2007) for Aspose.Grid. My platform is Vista Ultimate 64-bit and Visual Studio 2005, both with the most recent updates applied.

To clarify: Say my Aspose.Grid has 10 rows. I cycle through those 10 rows, top to bottom. For each row I test for a condition. If the condition is true, I color cell (X) Red, if the condition is false, I color cell (X) Green. Walking through the code, each row is correctly tested and colored. Now say Row 10, the last row in the grid tests false (Green). When the grid redisplays, ALL rows cell (X) are Green. No cells are colored Red.

This is happening to all the Aspose.Grids in my application (6). It is a new behavior that is a result of (either) changing to Vista Ultimate or applying the latest Aspose.Grid patch, I don;t know which. Unfortunately, it was discovered by my client after both updates were made.

Does this help?

Hi,

I don't have 64-bit vista environment here but some of our clients do use this env. and work fine with the grid. Have your code works fine before with the grid or after you upgrade the problem have been shown. Could you test it with other machine with different plateform. We will also check to figure out the issue. And Is it possible to create a sample test project, zip the files and post it here to reproduce it. We really appreciate your workaround.

Thank you.

Hi,

In databinding mode, all the cells in a column will share one style object. This behavior reduces the total style object instance count and improves the overall performance. If you want set a unique style for a particular cell, you should create a standalone style object for that cell.

// create a new style object

Aspose.Grid.Web.TableItemStyle style1 = new Aspose.Grid.Web.TableItemStyle();

// copy from the cell's style

style1.CopyFrom(cell1.Style);

style1.ForeColor = Color.Red;

cell1.Style = style1;

Thank you Henry, Amjad -

The following code works to color individual cells in the updated Aspose.Grid control in ASP.Net:

public void ColorDGCells(string _callType, int _index, int _cell)

{

WebWorksheet sheet = dg.WebWorksheets[dg.ActiveSheetIndex];

switch (_callType.ToLower())

{

case "red":

{

Aspose.Grid.Web.TableItemStyle style1 = new Aspose.Grid.Web.TableItemStyle();

style1.ForeColor = Color.White;

style1.BackColor = Color.Red;

sheet.Cells[_index, _cell].Style = style1;

} break;

case "green":

{

Aspose.Grid.Web.TableItemStyle style1 = new Aspose.Grid.Web.TableItemStyle();

style1.ForeColor = Color.White;

style1.BackColor = Color.Green;

sheet.Cells[_index, _cell].Style = style1;

} break;

}

}