Look at your code:
string studname;
string studid;
Session["StudName"] = studname;
Session["StudID"] = studid;
What value is in
studname
or
studid
when you try to set the value of the session variable?
None - so it is an
unassigned local variable
: it does not have any value assigned when you use it for the first time.
Set it to a value, and all will be well:
string studname = "";
string studid = "";
Session["StudName"] = studname;
Session["StudID"] = studid;