随笔-20  评论-32  文章-9  trackbacks-1

<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)  编辑 收藏 网摘

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-11-09 21:45 编辑过
Google站内搜索

相关文章:

相关链接: