views:

270

answers:

1

Hello all,

I am using c#.net.

Within my Gridview I am trying to set the SelectedRowStyle to different colours depending on which appointment the user has selected so need to change the backColor of the SelectedRow within my code behind.

When I try the code below, I get the the error below

Non-invocable member 'System.Web.UI.WebControls.Style.BackColor' cannot be used like a method.

protected void GridView_SelectedIndexChanged(object sender, EventArgs e)
{
   GridViewRow myRow = GridView.Rows[GridView.SelectedIndex];
   TableCell myCell = myRow.Cells[1];

   var appDetails = appRepos.GetApp(Convert.ToInt32(myCell.Text));

   switch (appDetails.appID)
   {
      case 1:
            GridView.SelectedRowStyle.BackColor(System.Drawing.Color.FromArgb(248, 231, 231));
            break;
      case 2: 
            GridView.SelectedRowStyle.BackColor(System.Drawing.Color.FromArgb(238, 221, 221));
            break;
    }

}

Thanks in advance for any help

Clare

+1  A: 

BackColor is a property, not a method. If you want to set it, use the assignment operator, e.g.

GridView.SelectedRowStyle.BackColor = Color.FromArgb(248, 231, 231);
Jon Skeet