从一个页面转移的DropDownList值到下一个 [英] Transferring DropDownList values from one page to the next

查看:107
本文介绍了从一个页面转移的DropDownList值到下一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2页,均与3类似DropDownLists。第一个DropDownList需要之前的第三选择第二,和第二(其然后填充一个gridview)之前进行填充。

I have 2 pages, both with 3 similar DropDownLists. The first DropDownList needs to be populated before selecting the second, and the second before the third (which then populates a gridview).

通常情况下,用户将看到一个页面上的数据,点击一个按钮,然后查看下一个页面(通常具有相同的DropDownList选择)上的数据。有什么办法能有dropdownlists pre-填充了他们的老选择?

Usually, a user will view data on one page, click a button, and then view data on the next page (usually with the same DropDownList selections). Is there any way to have the dropdownlists pre-populated with their old selections?

推荐答案

您可以从一个页面使用 previousPage 参数的ASP值传递给对方。网为您提供。一个小例子:

You can pass values from one page to the other using the PreviousPage parameter that asp.net provides you. A small example:

您设定的提交按钮第二页为:

You set the second page on the submit button as:

PostBackUrl="SecondPage.aspx"

在SecondPage.aspx声明,你可以得到的信息

On SecondPage.aspx you declare where you can get informations

<%@ PreviousPageType VirtualPath="~/FirstPage.aspx" %>

和您......让他们

and you get them by...

if (Page.PreviousPage != null)
{
    if(Page.PreviousPage.IsCrossPagePostBack == true)
    {
        // and get the controls of the previous page as
        var SomeVariable = PreviousPage.DropDownlListId.SelectedValue;
    }
}

一些参考。结果
在ASP.NET网页中搜索 跨页投递
<一href=\"http://stackoverflow.com/questions/3036422/asp-net-how-to-access-public-properties/3036710#3036710\">ASP.NET如何访问公共属性?
结果
<一href=\"http://stackoverflow.com/questions/3736445/cross-page-postbacks-and-back-again-retaining-data-from-source-page/3736506#3736506\">Cross-page回发,然后再返回保留数据从源代码页结果
<一href=\"http://stackoverflow.com/questions/10124030/cross-page-posting-is-it-a-good-pratice-to-use-$p$pviouspage-in-asp-net\">Cross-page张贴。它是一个很好的初步实践使用previousPage在Asp.net?

这篇关于从一个页面转移的DropDownList值到下一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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