OnRowCreated="gridStatistic_RowCreated private void FillUI() { gridStatistic.DataSource = dtStatistic; gridStatistic.DataBind(); } protected void gridStatistic_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { if (dtStatistic != null && dtStatistic.Rows.Count > 0) { decimal InfoReward = Convert.ToDecimal(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoReward")]); decimal InfoMoney = Convert.ToDecimal(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoMoney")]); if (InfoMoney > InfoReward) { e.Row.Cells[3].ForeColor = System.Drawing.Color.Red; } } } } ---------------或:---decimal数值对比-- protected void gridStatistic_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { if (dtStatistic != null && dtStatistic.Rows.Count > 0) { decimal InfoReward = Convert.ToDecimal(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoReward")]); decimal InfoMoney = Convert.ToDecimal(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoMoney")]); decimal cs = InfoMoney - InfoReward; if (cs>0) { e.Row.Cells[3].ForeColor = System.Drawing.Color.Red; } } } } -------------- protected void gridStatistic_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { if (dtStatistic != null && dtStatistic.Rows.Count > 0) { string InfoMoney=""; decimal InfoReward = Convert.ToDecimal(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoReward")]); InfoMoney = Convert.ToString(dtStatistic.Rows[e.Row.RowIndex].ItemArray[dtStatistic.Columns.IndexOf("InfoMoney")]); if (InfoMoney == "") InfoMoney ="0"; if (Convert.ToDecimal(InfoMoney) > InfoReward) { e.Row.Cells[3].ForeColor = System.Drawing.Color.Red; } } } }