GridView模板列中控件获取当前行的索引

这种方法不用创建RowCommand事件取得Row中的值
直接在Button的Click事件中
prootected void Button1_Click(object sender, EventArgs e)
{

Button NowBtn =(Button)sender;
TableCell cell = (TableCell)NowBtn.Parent;
GridViewRow iRow =(GridViewRow)cell.Parent;
//获取主键列的值
this.IdValue = Convert.ToInt32(iRow.Cells[主键列序号].Text);
}

posted @ 2009-03-20 16:36  潇客的技术博客  阅读(820)  评论(1编辑  收藏  举报