如何在gridview中获取列索引值

问题描述:

我的gridview有autogeneratecolumns = true,我想获取用户点击gridview单元格的特定列索引值。如果用户点击第三行,第五列的单元格,那么它将显示第三行和第三列的标题文本。第五栏。如何获取特定列索引值。请帮帮我。



My gridview has autogeneratecolumns = true and I want to get the specific column index value of where the user click on the gridview cell. If the user clicks on the cell of third row, fifth column, then it will show the Header text of Third Row & Fifth Column. How can I get the specific column index value. Please help me out.

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    Label1.Text = "RowHeader - " + GridView1.SelectedRow.Cells[0].Text + " and ColumnHeader - " + GridView1.HeaderRow.Cells[0].Text;
}

最后我使用下面的jQuery做了这个......



Finally I did this using the below jQuery...

<script type="text/javascript">


(document).ready(function(){
(document).ready(function () {


('#GridView1> tbody> tr> td')。click(function(){
var col =
('#GridView1>tbody>tr>td').click(function () { var col =