简体   繁体   English

C#gridview行onclick

[英]C# gridview row onclick

I notice there is a "AutoGenerateSelectionButton" function but it's not really what I want. 我注意到有一个“AutoGenerateSelectionButton”函数,但它并不是我想要的。 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? 如何在不编写客户端javascript函数的情况下实现这一目标?

Assuming this is a webform, you need to access SelectedIndexChanged event of the gridview using a codebehind file. 假设这是一个webform,您需要使用代码隐藏文件访问gridview的SelectedIndexChanged事件。

from here you can modify properties 从这里你可以修改属性

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM