我想将多个会话变量传递给多个asp页面。但是,只有最后一个ImageID和Extention值会传递到asp页面。我需要运C#会话变量
int key = Convert.ToInt32(StockSummary.SelectedRow.Cells[6].Text);
int index = 1;
try
{
transportFbConn.Open();
if (transportFbConn.State == ConnectionState.Closed)
{
transportFbConn.Open();
}
var sqlquerry = String.Format("select image_key,File_EXT from IMAGE_LIST where SOURCE_PK = {0}", key);
transportFbCommand = new FbCommand(sqlquerry, transportFbConn);
transportFbReader = transportFbCommand.ExecuteReader();
if (transportFbReader.HasRows)
{
while (transportFbReader.Read())
{
ImageID = transportFbReader.GetString(0);
extention = transportFbReader.GetString(1);
//Open PDF:
if (ImageID != "")
{
Session.Add("IMGID", ImageID);
Session.Add("Ext", extention);
Response.Write(string.Format("<script>window.open('{0}','_blank');</script>", "Trace"+index+".aspx"));
}
else
{
this.ErrorLabel.Text = "No Trace Information found for Part Number : " + this.TextTextBox.Text;
}
index++;
}
}
我尝试了数组列表,但我得到的对象空引用:
int key = Convert.ToInt32(StockSummary.SelectedRow.Cells[6].Text);
int index = 1;
int arrayindex = 0;
ArrayList imageid = new ArrayList();
ArrayList extention = new ArrayList();
try
{
transportFbConn.Open();
if (transportFbConn.State == ConnectionState.Closed)
{
transportFbConn.Open();
}
var sqlquerry = String.Format("select image_key,File_EXT from IMAGE_LIST where SOURCE_PK = {0}", key);
transportFbCommand = new FbCommand(sqlquerry, transportFbConn);
transportFbReader = transportFbCommand.ExecuteReader();
if (transportFbReader.HasRows)
{
while (transportFbReader.Read())
{
imageid.Insert(arrayindex, transportFbReader.GetString(0));
extention.Insert(arrayindex, transportFbReader.GetString(1));
//Open PDF:
if (ImageID[arrayindex].ToString() != "")
{
Session.Add("IMGID", ImageID[arrayindex]);
Session.Add("Ext", extention[arrayindex]);
Response.Write(string.Format("<script>window.open('{0}','_blank');</script>", "Trace"+index+".aspx"));
}
else
{
this.ErrorLabel.Text = "No Trace Information found for Part Number : " + this.TextTextBox.Text;
}
index++;
arrayindex++;
}
}
该会话是一个'键''值'存储。你是否试图在同一个密钥下存储多个值? – TheNorthWes