每當我直接進入我的頁面(mypage.aspx)它返回一個錯誤:(?mypage.aspx SR =真)如果我添加一個查詢字符串查詢字符串驗證問題
Object not set to object not set to an instance of an object.
它的工作原理,但我檢查,確保在它評估它有一個值之前,它不應該有一個值。那麼,爲什麼我直接訪問頁面時會出現錯誤?
if (!IsPostBack)
{
string qu1 = "";
string qu2 = "";
string qu3 = "";
if (Request.QueryString["qu1"] != null)
{
qu1 = Request.QueryString["qu1"].ToString();
if (qu1 != "")
{
qu1DropDownList.SelectedValue = industry;
}
}
if (Request.QueryString["qu2"] != null)
{
qu2 = Request.QueryString["qu2"].ToString();
if (qu2 != "")
{
qu2DropDownList.SelectedValue = category;
}
}
fillDropDownList();
if (Request.QueryString["qu3"] != null)
{
qu3 = Request.QueryString["qu3"].ToString();
if (qu3 != "")
{
qu3tDropDownList.SelectedValue = product;
}
}
}
string search = "";
string qu1value = IndustryDropDownList.SelectedValue;
string qu2value = ProductCategoryDropDownList.SelectedValue;
string qu3value = ProductDropDownList.SelectedValue;
using (SPSite site = new SPSite("SITE"))
using (SPWeb oWebsiteRoot = site.OpenWeb())
{
SPList oList = oWebsiteRoot.Lists["SpacesInfo"];
SPListItemCollection items = null;
if (Request.QueryString["sr"] != "" && Request.QueryString["sr"] != null)
{
search = Request.QueryString["sr"].ToString();
if (search == "true")
{
if (indvalue == "select" & catvalue == "select")
{
items = oList.Items;
}
else if (indvalue != "select" & catvalue != "select" & provalue != "select")
{
SPQuery query = new SPQuery();
query.Query = "MYQUERY";
items = oList.GetItems(query);
}
else if (indvalue != "select" & catvalue != "select" & provalue == "select")
{
SPQuery query = new SPQuery();
query.Query = "MYQUERY";
items = oList.GetItems(query);
}
else if (indvalue != "select" & catvalue == "select")
{
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='Industry' /><Value Type='Choice'>" + indvalue +
"</Value></Eq></Where>";
items = oList.GetItems(query);
}
else if (indvalue == "select" & catvalue != "select" & provalue == "select")
{
SPQuery query = new SPQuery();
query.Query = "MYQUERY";
items = oList.GetItems(query);
}
else if (indvalue == "select" & catvalue != "select" & provalue != "select")
{
SPQuery query = new SPQuery();
query.Query = "MYQUERY";
items = oList.GetItems(query);
}
else
{
errorLabel.Text = "Please contact the administrator.";
items = oList.Items;
}
}
else
{
items = oList.Items;
}
}
DataTable table = new System.Data.DataTable();
table = items.GetDataTable();
spacerepeater.DataSource = table;
spacerepeater.DataBind();
}
凡究竟異常發生的?什麼線? –