单击GridView某行获取该行某列内容并显示_[Asp.Net教程]
方法1:单击GridView某行获取该行某列值并显示在一个TextBox中
C# code //GV行添加JS事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "gvselchange('" + e.Row.Cells[0].Text + "')");
}
}
JScript code
function gvselchange(o1)
{
document.getElementById("<%=TextBox1.ClientID %>").value=o1;
}
方法2:
执行的是单击某一行根据这一行内容弹出一个窗体
C# code
protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = String.Format("window.parent.document.frames(’right’).location = ’../Report/Test.aspx?id={0}’", e.Row.Cells[1].Text);
}
}
来源:csdn