将字符串数组从一个ASP页传递到另一页 [英] Passing a String Array from one ASP page to another

查看:116
本文介绍了将字符串数组从一个ASP页传递到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将DropDownList从一页传递到另一页.
来自第一个ASPX页的代码是:

I am trying to pass a DropDownList from one page to the other.
The code from the first ASPX page is:

if (validLogon)

       {
           Session["FacilityNames"] = FacilityNames;
           Session["User"] = txtUser;
           Response.Redirect("Default2.aspx");
       }


其中FacilityName是字符串数组
来自第二个ASPX页面的代码是:


Where FacilityName is a string array
The code from the Second ASPX page is:

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string fac = (string)Session["FacilityNames"].ToString();

           foreach (var sss in fac)
        {
            ddlFacilities.Items.Add(sss.ToString());
        }


fac字符串变量填充为"System String []而不是从首页指定的字符串数组.


The fac string variable is populated with "System String[] instead of the string array specified from the first page.

推荐答案

ToString()是会话的ToString重载.因此,如下所示.


ToString() is overload of ToString for session. so write like below.


protected void Page_Load(object sender, EventArgs e)
    {
        string fac = (string)Session["FacilityNames"];

           foreach (var sss in fac)
        {
            ddlFacilities.Items.Add(sss.ToString());
        }


我相信下面的链接对您有用

http: //stackstackflow.com/questions/2948805/如何将一个字符串数组从一个ASP.NET页面发送到另一个
I beleive this below link would be useful to you

http://stackoverflow.com/questions/2948805/how-can-i-send-an-array-of-strings-from-one-asp-net-page-to-another


这篇关于将字符串数组从一个ASP页传递到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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