Something strange is happening in my web application. I have a static dictionary that I use to hold a collection of simple objects that hold two variables:
static Dictionary<string, linkButtonObject> linkButtonDictonary = new Dictionary<string, linkButtonObject>();
I have a gridview with linkbuttons, data about each one is associated with its button.UniqueId in the Dictionary:
protected void hoursReportGridView_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
LinkButton btn = (LinkButton)e.Row.FindControl("taskLinkButton");
linkButtonObject currentRow = new linkButtonObject();
currentRow.storyNumber = e.Row.Cells[3].Text;
currentRow.TaskName = e.Row.Cells[5].Text;
linkButtonDictonary.Add(btn.UniqueID, currentRow);
}
Then when the linkbutton is clicked I pull look up the values in the dictionary using the UniqueId, use them in a SQL query and use the retrieved data to populate a gridview, labels and show a popup:
protected void taskLinkButton_Click(object sender, EventArgs e)
{
//create linkbutton object from sender
LinkButton btn = (LinkButton)sender;
//get a list of data relevant to column
string[] infoData = getInfoData(linkButtonDictonary[btn.UniqueID].storyNumber,
linkButtonDictonary[btn.UniqueID].TaskName);
//assign content of list to labels and gridview
productDatabaseLabel.Text = infoData[0];
storyNumberDatabaseLabel.Text = infoData[1];
taskDatabaseLabel.Text = infoData[2];
pointPersonDatabaseLabel.Text = infoData[3];
SqlDataSource6.SelectParameters["storynumber"].DefaultValue = linkButtonDictonary[btn.UniqueID].storyNumber;
SqlDataSource6.SelectParameters["tasktitle"].DefaultValue = linkButtonDictonary[btn.UniqueID].TaskName;
infoGridView.DataBind();
//show popup
MPE.Show();
}
This all works great and I can click any of the linkbuttons and they correctly create and populate the popup and show it.
My issue is that if I leave the page idle for a few minuites and then click a linkbutton I get the error:
What am I doing wrong and how do I fix it?