如何在asp.net C#中的焦点事件中从Gridview Textbox获取rowindex

时间:2013-03-16 06:09:08

标签: asp.net c#-4.0

我使用templatefield在Gridview中使用Textbox。一切都运作良好。但我的问题是,每当文本框获得焦点时,我都需要该gridview的rowindex 你能帮助我吗? 提前致谢

1 个答案:

答案 0 :(得分:1)

也许这是DataGridViewCell.RowIndex Property

private void getCurrentCellButton_Click(object sender, System.EventArgs e)
{
  string msg = String.Format("Row: {0}, Column: {1}",
    dataGridView1.CurrentCell.RowIndex,
    dataGridView1.CurrentCell.ColumnIndex);
  MessageBox.Show(msg, "Current Cell");
}