将字符串数组从一个ASP页传递到另一页

编程入门 行业动态 更新时间:2024-10-11 19:22:18
本文介绍了将字符串数组从一个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/questions/2948805/如何将一个字符串数组从一个ASP.NET页面发送到另一个 I beleive this below link would be useful to you stackoverflow/questions/2948805/how-can-i-send-an-array-of-strings-from-one-asp-net-page-to-another

更多推荐

将字符串数组从一个ASP页传递到另一页

本文发布于:2023-11-06 03:25:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562605.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   字符串   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!