随笔-20  评论-32  文章-9  trackbacks-1
  2007年11月9日

<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 @ 2007-11-09 21:43 冷风旋 阅读(114) | 评论 (0)编辑