日期:2014-05-17  浏览次数:20723 次

aspxgridview获取从表选中行的值
本帖最后由 yangh1688 于 2012-04-23 12:32:30 编辑
aspxgridview主从表,获取从表选中行的值。如主表为Mastergrid,从表为Detailgrid,选中从表的某行后,获取选中行的单元格值。




------解决方案--------------------
e.Row.Cells[0].Text 
------解决方案--------------------
你可以这样    在行绑定里面
protected void gvbranch_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
           //取出选中行指定列的值
            调用js函数ChkID(参数)  吧改值付给 一个隐藏控件
            e.Row.Attributes.Add("onclick", "ChkID('" + e.Row.Cells[2].Text + "');");
        }
    }



js:
ChkID(id)
{
   document.getElementById("hfRecID").value=id;
}


当你使用该值的时候  就去调  隐藏控件hfRecID的值hfRecID.Value
------解决方案--------------------
http://www.cnblogs.com/chenping-987123/archive/2010/08/27/1809877.html