爲什麼此代碼會拋出NullReferenceException
?查詢字符串錯誤
例外:
System.NullReferenceException: Object reference not set to an instance of an object.
代碼:
if ((string.IsNullOrEmpty(Request.QueryString["Sno"].ToString()))
&& (string.IsNullOrEmpty(Request.QueryString["Name"].ToString())))
{
lblBookedBy.Text = "";
lblSno.Text = "";
}
else
{
lblBookedBy.Text = Request.QueryString["Name"].ToString();
lblSno.Text = Request.QueryString["Sno"].ToString();
}
你檢查了我的答案嗎? – Arshad 2013-03-15 10:59:11
答其他人在這裏回答他們的想法是正確的嗎? – TalentTuner 2013-03-15 11:15:39