I am getting there! Need a tiny bit of extra help.
My gridview has 2 columns. One is Party (text) and one is a Select column with a Select button in every row.
This is what I want: Change the color of the Select button to Red if the Party is Republican. Otherwise set it to Blue.
Below is the code I have. Please help me fill in the missing code.
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "Republican")
{
// WHAT SHOULD I DO HERE???
}
}
}
Instead of setting the color in the codebehind you could just set the CSS Class of your button in the aspx file, using gridview’s template fields:
and then defining the CSS Class in your stylesheet.