问题描述
- 请大师帮助解决一下“从数据库表中取去判断”
-
private void gridView1_RowStyle(object sender, RowStyleEventArgs e)
{//读取使用年限值 SqlDataReader sqlread = database.getread("select Pjmc,Synx from tb_Synx"); if (sqlread.Read()) { lab_Synx.Text = sqlread["Synx"].ToString(); lab_Pjmc.Text = sqlread["Pjmc"].ToString(); sqlread.Close(); } GridView View = sender as GridView; if (e.RowHandle >= 0) { int year = Convert.ToInt32(lab_Synx.Text); string pjmc = View.GetRowCellDisplayText(e.RowHandle, View.Columns["Pjmc"]); int Synx1 = Convert.ToInt32(View.GetRowCellDisplayText(e.RowHandle, View.Columns["Synx"])); if (Synx1 >= year && pjmc == lab_Pjmc.Text) { e.Appearance.BackColor = Color.Salmon; e.Appearance.BackColor2 = Color.SeaShell; } } } }
时间: 2024-12-31 01:51:49