I have a code that inserts <key,value>
into Dictionary
, put Dictionary
into ViewState
and than later on retrieves that Dictionary
from ViewState
.
This is when I populate Dictionary
and put it in ViewState
:
foreach (DataTable table in IsoDataSet.Tables)
{
foreach (DataRow dr in table.Rows)
{
if (dr.IsNull("email"))
{
email = "No emails on file";
}
else
{
email = (String)dr["email"];
}
oldEmails.Add((String)dr["isonum"], email);
ViewState["OldEmails"] = oldEmails;
}
}
Then I need to get Dictionary
back from ViewState
:
oldEmails = (Dictionary<String, String>)ViewState["OldEmails"];
When doing oldEmails.Count
, I see that I have the same amount of records in my Dictionary
as were placed there in the beginning.
But when I do a check: if(oldEmails.ContainsKey(strIsoNum))
it fails., event though I have a data in my Dictionary with the given key
What am I doing wrong?