根据datagrid的列里的数值大小,用不同的颜色在datagrid的单元格中标记出来
可是我这样转换为什么会出问题 int temp1=int.Parse (e.Item .Cells [17].Text) ;
int temp2=int.Parse (e.Item .Cells [16].Text) ; if(temp1<temp2)
{
for(int i=0;i<e.Item .Cells .Count ;i++)
{
e.Item .Cells [16].BackColor =System .Drawing .Color.Yellow ;
}
}为什么总是报错,这种转换格式有问题吗?
可是我这样转换为什么会出问题 int temp1=int.Parse (e.Item .Cells [17].Text) ;
int temp2=int.Parse (e.Item .Cells [16].Text) ; if(temp1<temp2)
{
for(int i=0;i<e.Item .Cells .Count ;i++)
{
e.Item .Cells [16].BackColor =System .Drawing .Color.Yellow ;
}
}为什么总是报错,这种转换格式有问题吗?
{
e.Item .Cells [16].BackColor =System .Drawing .Color.Yellow ; }这里让人看不懂了,循环中的语句与循环没啥关系,
e.Item .Cells [16].BackColor =System .Drawing .Color.Yellow ;
16 是不是溢出了
private void (控件名)_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer )
{
if (e.Item.ItemType != ListItemType.Separator)
{
if (e.Item.Cells[3].Text == "补考")
{
e.Item.Cells[3].ForeColor = Color.Yellow;
}
if (e.Item.Cells[3].Text == "重考")
{
e.Item.Cells[3].ForeColor = Color.Red;
}
}
}
}
比如说
e.Item.cell[1]<e.Item.cell[2]
两列数值型的单元进行比较