Change Background Color of ASP:GridView Based On Text
Generally, styling should be handled using client side methods such as using css/javascript so I would recommend you do some brushing up on that side. Never the less I was like you when I first started and just jumped straight into c# so here is a purely c# based solution :).

If it's only ever going to be the first row that needs to be shaded grey you can just reference that row when the binding in complete. The event you're currently subscribing to OnRowDataBound will fire for every row. There is another event that can be accessed once all rows are completed called OnDataBound.

First thing to do would be to register this event in the html markup of your gridview, using the same approach you used to register the OnRowDataBound event.

&lt;asp:gridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnDataBound="GridView1_OnDataBound"&gt;&lt;/asp:gridView&gt;


Then you can code up the event in your c#.

protected void GridView1_OnDataBound(object sender, EventArgs e)
{
    if(GridView1.Rows.Count &gt; 0) //Check there are rows bound
    {
        var Row = GridView1.Rows[0];// Get The First Row - you may have a header row. If this is the case change 0's to 1's!

        Row.BackColor = System.Drawing.Color.Gray;// Assign the back color
    }
}