如何在我的网格视图中获取文本框的单元格索引
本文关键字:取文本 单元格 索引 获取 我的 网格 视图 | 更新日期: 2023-09-27 18:30:08
如何在我的网格视图中获取文本框的单元格索引?
我的代码:
protected void txt_1_TextChanged(object sender, EventArgs e)
{
int progSer = int.Parse(Session["prog"].ToString());
RadNumericTextBox txt = (RadNumericTextBox)sender;
GridViewRow r = (GridViewRow)txt.NamingContainer;
//now i want to get the cell index of my fired textbox ,say this text box is in the second column so i want to get index 2
}
您可以使用TableCellCollection.GetCellIndex
和循环来查找TextBox
:的单元格
TableCell cell = null;
Control parent = txt;
while ((parent = parent.Parent) != null && cell == null)
cell = parent as TableCell;
int indexOfTextBoxCell = -1;
if (cell != null)
indexOfTextBoxCell = r.Cells.GetCellIndex(cell);