<asp:Button ID="Button1" CommandName="Update" CommandArgument='<%#Eval("Row_ID")%>' />
在GridView的RowCommand事件中写:
protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
Response.Write(e.CommandArgument.ToString());//写出的值就是该行绑定的主键值
}
}
prootected void Button1_Click(object sender, EventArgs e)
{
Button NowBtn =(Button)sender;
TableCell cell = (TableCell)NowBtn.Parent;
GridViewRow iRow =(GridViewRow)cell.Parent;
//返回控件所在行的索引值
Response.Write(iRow.Text);
}
posted on 2007-11-09 21:43
冷风旋 阅读(114)
评论(0) 编辑 收藏 网摘