请帮助我,我如何在每列中找到最高的数字并将其格式化以使其变为粗体。
答案 0 :(得分:5)
请使用这种方法。
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
string[] numericColumns = { "OrderID", "Freight", "Freight1", "Freight2" };
foreach (string uniqueName in numericColumns)
{
int index = -1;
decimal maxNumber = decimal.MinValue;
foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
{
decimal currentNumber = decimal.Parse(dataItem[uniqueName].Text);
if (currentNumber > maxNumber)
{
maxNumber = currentNumber;
index = dataItem.ItemIndex;
}
}
if (index >= 0)
{
GridTableCell cell = (RadGrid1.Items[index] as GridDataItem)[uniqueName] as GridTableCell;
cell.BackColor = System.Drawing.Color.LightBlue;
}
}
}
希望这对你有用。