代码:
private void Page_Load(object sender, System.EventArgs e){ // 在此处放置用户代码以初始化页面 this.sqlDataAdapter1.Fill(this.dataSet11); //this.DataGrid1.DataSource = this.dataSet11.Tables[1]; this.DataGrid1.DataBind();}
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ if(e.Item.ItemType!=ListItemType.Header&&e.Item.ItemType!=ListItemType.Footer) {//3条记录显示黄绿色,下3条记录显示红色 if((e.Item.ItemIndex)%6<3) { e.Item.BackColor = Color.YellowGreen; } else { e.Item.BackColor = Color.Red; } }}