This is basically due to the Session object.
This is because the session is not having value i guess.
So do one thing before accessing the Session value check whether the session is exists or not. If exists then only assign this session value to variable.
Example:
Put this code in the page_Load method.First comment the Session initialization and check later on un comment and check this. Hope you will get the answer what you are searching.
Session["ddlCountry"] = "US";
if (Session["ddlCountry"]!=null)
{
string cntry = Session["ddlCountry"].ToString();
if (cntry == "US")
{
lnkUrl.Text = string.Empty;
if (lnkUrl == null || lnkUrl.Text.Length == 0)
{
lnkUrl.Text = "http://www.google.com";
}
}
}
else
{
lnkUrl.Text="Value not present in Session.";
}
Best of luck.