2007年3月26日星期一

RowDataBound

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int unitsInStock = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "status"));
            switch(unitsInStock)
            {
                case 0:
                    e.Row.Cells[5].Text = "Waiting Part I Audit";
                    e.Row.BackColor = System.Drawing.Color.Yellow;
                    break;
                case 1:
                    e.Row.Cells[5].Text = "Waiting Part II Audit";
                    e.Row.BackColor = System.Drawing.Color.YellowGreen;
                    break;
                case 2:
                    e.Row.Cells[5].Text = "Apllication is rejected";
                    e.Row.BackColor = System.Drawing.Color.Red;
                    break;
                case 3:
                    e.Row.Cells[5].Text = "Application is accepted";
                    e.Row.BackColor = System.Drawing.Color.White;
                    break;
                default:
                    e.Row.Cells[5].Text = "Others";
                    e.Row.BackColor = System.Drawing.Color.White;
                    break;
 
            }
        }
    }
 
 
 

没有评论: