繁体   English   中英

如何在asp.net c#中将GridView的值从一个页面传递到另一个页面?

[英]How to pass value of GridView from one page to another in asp.net c#?

如何将网格视图的值从一个页面传递到另一个页面? 这是我的代码:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType != DataControlRowType.Header)
        {
        //  //  e.Row.Cells[0].Text = "<a href=" + "javascript:window.open('http://www.google.com')" + " >" + e.Row.Cells[0].Text + "</a>";
            e.Row.Cells[0].Text = "<a id=\"linkres\"  CssClass=\"dgrid\" runat =\"server\"  href= \"javascript:window.open('Preview.aspx'),_self\" >" + e.Row.Cells[0].Text + "</a>";
        }

    }

我需要在GridView上传递所选项的值,然后检索到另一个页面。

每当您需要访问多个页面上的某些数据时,您有以下选择:

  1. 将其存储在会话变量中。
  2. 将它传递给URL的查询字符串。
  3. 将其存储在数据库中/将其拉到另一页上。
  4. 将其存储在cookie中。

对于你正在做的事情,我通常会选择第一个。

Session["GridViewValue"] = e.Row.Cells[0].Text;

在另一页上

string something = Session["GridViewValue"].ToString();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM