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
305
UltraWebGrid: Getting a cell value on each row and styling
posted

Hi all,

 I have a UltraWebGrid on a page and I need to format one column's cell values.

Pseudo Code: 
If the cell valus is 0<value<100, set the cell's fontcolor to red, else set it to green.

here is the code I have tried on the RowDataBound event:

protected void UltraWebGrid1_DataBound(object sender, EventArgs e)

{

decimal PercentageAcheivedValue = Convert.ToDecimal(this.UltraWebGrid1.Rows.FromKey("GetPercentageAchieved").GetCellValue(UltraWebGrid1.Columns[3]));if (PercentageAcheivedValue >= 0.0M && PercentageAcheivedValue < 100.00M)

{

UltraGridRow thisRow = UltraWebGrid1.Rows.FromKey("GetPercentageAchieved");

thisRow.Style.Font.Bold = true;thisRow.Style.ForeColor = System.Drawing.Color.Red;

}

else

{

UltraWebGrid1.Rows.FromKey(
"GetPercentageAchieved").Style.ForeColor = System.Drawing.Color.Green;UltraWebGrid1.Rows.FromKey("GetPercentageAchieved").Style.Font.Bold = true;

}

}

 

Also here is the code for the column in question:

<igtbl:UltraGridColumn BaseColumnName="GetPercentageAchieved" Key="GetPercentageAchieved"

IsBound="True" DataType="System.Decimal" Format="N2" Width="25%">

<Header Caption="% Achieved">

<RowLayoutColumnInfo OriginX="3" />

</Header>

<Footer>

<RowLayoutColumnInfo OriginX="3" />

</Footer>

</igtbl:UltraGridColumn>

 

The error I get is on the RowDataBound event which says that i'm getting a null reference.

Therefore, my question is, how do I get the cell value of each row of a particular column on RowDataBound?

 

Thanks in advance.

Parents Reply Children