- <form id="form1" runat="server">
- <div>
- <asp:GridView ID="GridView1" runat="server" CellPadding="6" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
- <Columns>
- <asp:BoundField DataField="Id" HeaderText="Id"/>
- <asp:BoundField DataField="Name" HeaderText="Name"/>
- <asp:BoundField DataField="City" HeaderText="City"/>
- <asp:BoundField DataField="Salary" HeaderText="Salary"/>
- </Columns>
- </asp:GridView>
- </div>
- </form>
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //Checking the RowType of the Row
- if(e.Row.RowType==DataControlRowType.DataRow)
- {
- //If Salary is less than 10000 than set the row Background Color to Cyan
- if(Convert.ToInt32(e.Row.Cells[3].Text)<10000)
- {
- e.Row.BackColor = Color.Cyan;
- }
- }
- }