All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
单击GridView某行获取该行某列内容并显示_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:31:56 Browse times: 360 Comment times: 0

单击GridView某行获取该行某列内容并显示_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

单击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




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.