如何从一个页面的一个网格视图到另一个页面的另一个网格视图显示所选数据(使用复选框)? [英] How to display selected data(using checkbox) from one gridview of one page to another gridview of another page?

查看:87
本文介绍了如何从一个页面的一个网格视图到另一个页面的另一个网格视图显示所选数据(使用复选框)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我有一个5行的网格视图,我使用复选框选择2行,我想要的是我需要在另一个gridview中的另一个页面中显示这些选定的2行gridview。



i需要使用不同的网格视图即gridview2显示另一页中一页的gridview1的所选数据(使用复选框)。



plz help我出去了。



一件重要的事情是我不想直接重定向到第二页而是应该存储在第二页中并且在运行第二页之后我应该显示那些选中的数据行。

for example I have a gridview of 5 rows in that i am selecting 2 rows using checkbox and what i want is i need to display these selected 2 rows of gridview in another page in another gridview.

i need to display selected data(using checkbox) of gridview1 of one page in another page using different gridview ie gridview2.

plz help me out.

One important thing is i dont want to redirect directly to second page instead it should be stored in second page & after running second page i should display those selected data rows.

推荐答案

http://www.aspsnippets.com/Articles/Pass-Selected-Row-of-ASPNet-GridView-control-to-another- Page.aspx



Checkout
http://www.aspsnippets.com/Articles/Pass-Selected-Row-of-ASPNet-GridView-control-to-another-Page.aspx

Checkout


点击按钮后,创建一个新的DataTable(名为dtSelected),其中包含用于存储的列来自第一个数据表的已检查行的数据。然后你有两个选择:

1.将这个dtSelected存储在一个会话变量中,然后将一个Response.Redirect存储到新页面(称为GridViewPage2),就像这样

Upon button click, create a new DataTable (called "dtSelected") with columns to store the data from checked rows of the first data table. Then you have 2 options:
1. Store this "dtSelected" in a session variable, followed by a Response.Redirect to the new page (called "GridViewPage2"), like this
Session["dt"] = dt;
Response.Redirect("GridViewPage2.aspx");





2.将此dtSelected存储在上下文中。然后项目集合执行Server.Transfer到新页面,如下所示:


or
2. Store this "dtSelected" in a Context.Item collection then do a Server.Transfer to the new page, like this:

Context.Items.Add("dt", dt);
Server.Transfer("GridViewPage2.aspx");



接下来,在新页面的Page_Load上,执行以下操作:


Next, on the Page_Load of the new page, do something like this:

if (!this.IsPostBack)
{
    /*
    // option 1
    if (Session["dtSelected"] != null)
    {
        gvSelected.DataSource = Session["dtSelected"];
        gvSelected.DataBind();
    }
    */
    // option 2
    if (Context.Items["dtSelected"] != null)
    {
        gvSelected.DataSource = (DataTable)Context.Items["dtSelected"];
        gvSelected.DataBind();
    }
}



采用哪种方案?阅读 Response.Redirect()与Server.Transfer之间的差异后自行决定()ASP.NET中的方法 [ ^ ]。


这篇关于如何从一个页面的一个网格视图到另一个页面的另一个网格视图显示所选数据(使用复选框)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆