Yang
Yang

Reputation: 6912

C# gridview row onclick

I notice there is a "AutoGenerateSelectionButton" function but it's not really what I want. I want to be able to two things when a row is clicked (anywhere of the row):

  1. change the color of that entire row.
  2. get the value of a specific column and update another table accordingly.

How can I acheive that without writing client-side javascript functions?

Upvotes: 0

Views: 739

Answers (1)

Antarr Byrd
Antarr Byrd

Reputation: 26159

Assuming this is a webform, you need to access SelectedIndexChanged event of the gridview using a codebehind file.

from here you can modify properties

 protected void ChangedRow(object sender, EventArgs e)
        {
            this.GridView1.SelectedRow.BackColor = System.Drawing.Color.Red;
....
        }

Upvotes: 2

Related Questions