I am trying to pass multiple session variables to multiple asp pages. However, only the last ImageID and Extention values pass into the asp pages. I need to op
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++;
}
}
I tried the arraylist but I get the object null reference:
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++;
}
}
keyvaluestore. Are you trying to store more than one value under the same key?