<asp:GridView ID="Grid_product" runat="server" OnRowDataBound="Grid_product_RowDataBound"  AutoGenerateColumns="true">
  </asp:GridView>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ArrayList arrl = new ArrayList();
                arrl.Add("Profit"); arrl.Add("Lost"); arrl.Add("Null");                                 arrl.Add("Null"); arrl.Add("Lost"); arrl.Add("Profit"); al.Add("Profit");                this.Grid_product.DataSource = arrl;
                this.Grid_product.DataBind();
            }
        }

 protected void Grid_product_RowDataBound(object sender, Grid_productRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[0].Text == "Profit")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;
                }
                else if (e.Row.Cells[0].Text == "Lost")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Black;
                }
                else
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Green;
                }
            }
        }

Comments ( 0 )