Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Selecting a coloumn in a datagrid view

Options
  • 17-07-2006 12:21pm
    #1
    Closed Accounts Posts: 29


    Hi,

    I have a coloumn of select buttons in my gridview and what I am tring to do is that when the user selects the button, the background colour of the gridview will be highlighted. I am sure that something like this would be easily implemented, so far what I have tired is that when the button is clicked it call a
    GridViewCommandEvent args method. Below is my code
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridView1.SelectedRow.BackColor = System.Drawing.Color.Blue;         
        }
    

    I would have though that, that would work but it throws a runtime error. Can anybody help??


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Try it in the SelectedIndexChanged event instead, it'll work in there. I'd say your getting a NullReferenceException error. I don't think there is a selected row if you're using RowCommand, hence the null reference.


  • Closed Accounts Posts: 29 TowerMan


    Hey Evil Phil, thanks a million that worked out perfect for me.


Advertisement