Hi,
try as below.
Add, one hidden label "lblStatus" in gridview.
<templatecolumn visible="false">
<itemtemplate>
<asp:label id="lblStatus" runat="server" text="<%#Eval("Status") %>" xmlns:asp="#unknown"></asp:label>
</itemtemplate>
</templatecolumn>
if(e.Row.RowType == DataControlRowType.DataRow)
{
Button btn = (Button)e.Row.FindControl("btn");
Label lbl = (Label)e.Row.FindControl("lblStatus");
if(Convert.ToBoolean(lbl.Text))
{
btn.BackColor = System.Drawing.Color.Gray;
}
else
{
btn.BackColor = System.Drawing.Color.Green;
}
}
The label text will be binded by datasource from database. based on that status value, the button color can be changed.
Note that, the text for status would be "True" or "False" otherwise you can compare with data of your choice.
hope it helps.