数组在页面间传递 Session["myCartTable"]=数组;另一个页面中,接收就是了. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //sendstring strPR = null;for (int i=0;i<pr.Length;i++){ strPR += pr[i] + ";";}session["PR"] = strPR;//receivestring strPR = session["PR"].ToString();string[] pr = null;//pr为接收数组pr = strPR.Split(new char[] {';'}); 把数组设为public就行,以下是个测试:WebForm1.aspx.cs:namespace WebApplication1{ /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { public string[] arystr=new string[]{"1","2","3"}; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }}WebForm2.aspx.cs:namespace WebApplication1{ /// <summary> /// WebForm2 的摘要说明。 /// </summary> public class WebForm2 : System.Web.UI.Page { WebForm1 myewb=new WebForm1(); private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 Response.Write(myewb.arystr[0]+myewb.arystr[1]+myewb.arystr[2]); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }} zhangqiushui( 水):接收的pr数组是个string型,不能转换成double型啊? public partial class Array : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string[] a =new string[4]; for (int i = 0; i < 4;i++ ) { a[i] = (i + 1).ToString(); } Session["a"]=a; }}////////////////////////////////////////////////////public partial class GetArray : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string[] a = Session["a"] as string[]; for (int i = 0; i < 4;i++ ) { Response.Write(a[i]); } }}///////////////////////////////////////////////////////////所有问题都可照此解决 直接传过去就行了..那边也直接接收.string[] a = Session["a"] as string[]; 我需要发送的数组是double型,接收的数组也是double型,可是上面各位的答案都是string型的,那接下来的程序我就没办法做了,谁能提供一个直接将double型传到double型的程序?或者在接收页面将string型变换成double型的数组。 感觉数组内容不多的话,使用URL参数传递过去也很方便. 建一个Session会话变量也挺方便的. wap 网站中下拉框联动问题 用Asp.net如何在后台添加多个html控件及事件并点击是哪个控件触发的事件 div+css问题 SQLserver2005 Express不允许远程连接? 为什么我的电脑里“开始”下“程序”没有“WINDOWS文件加密”这个程序呢? 请问UEditor 样式过滤怎么不让过滤,ueditor为1.3.5版本 cas 单点登录 .net 急问高手!!! 如何用程序实现探测 IP 为202.114.0.241 的用户是否在线? config.web 求助,使用 SqlDataAdapter 怎么实现三层结构 检测登录用户在线问题
string strPR = null;
for (int i=0;i<pr.Length;i++)
{
strPR += pr[i] + ";";
}
session["PR"] = strPR;
//receive
string strPR = session["PR"].ToString();
string[] pr = null;//pr为接收数组
pr = strPR.Split(new char[] {';'});
WebForm1.aspx.cs:
namespace WebApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
public string[] arystr=new string[]{"1","2","3"};
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
WebForm2.aspx.cs:
namespace WebApplication1
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
WebForm1 myewb=new WebForm1();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面 Response.Write(myewb.arystr[0]+myewb.arystr[1]+myewb.arystr[2]);
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
{
protected void Page_Load(object sender, EventArgs e)
{
string[] a =new string[4];
for (int i = 0; i < 4;i++ )
{
a[i] = (i + 1).ToString();
}
Session["a"]=a;
}
}
////////////////////////////////////////////////////
public partial class GetArray : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] a = Session["a"] as string[];
for (int i = 0; i < 4;i++ )
{
Response.Write(a[i]);
}
}
}
///////////////////////////////////////////////////////////
所有问题都可照此解决
那边也直接接收.
string[] a = Session["a"] as string[];
建一个Session会话变量也挺方便的.