<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound"> <Columns> <asp:BoundField DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName" /> <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" /> <asp:BoundField DataField="CriticalLevel" HeaderText="Critical Level" SortExpression="CriticalLevel" /> </Columns> </asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRow pr = ((DataRowView)e.Row.DataItem).Row; int id = Convert.ToInt32(pr["Quantity"]); if(id==1) e.Row.Cells[2].BorderColor = System.Drawing.Color.Red; if(id < 1) e.Row.Cells[2].BorderColor = System.Drawing.Color.Blue; if(id==0) e.Row.Cells[2].BorderColor = System.Drawing.Color.Violet; } }
e.Row.BackColor = Drawing.Color.LightBlue e.Row.ForeColor = Drawing.Color.Black
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)