Resolution for First Error:
Have you defined
a
properly? I tried your code with below syntax and it runs without any Error.
try
{
string[] a = new string[]{};
for (int j = 0; j <= Session.Keys.Count - 1; j++)
{
a[j] = Session.Keys[j];
}
}
catch (Exception ex)
{
string error = ex.Message;
}
Resolution for Second Error:
Debug your code and check value of
dt
, it should not be null. Also check what value you are getting from
dt.Rows[ctr]["Serial"]
.