我无法理解如何Page.Request.QueryString
和Page.Session
工作。我将如何分配name
给这个string
protected override void Render(HtmlTextWriter output)
{
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlCommand sqlCommand = new SqlCommand();
StringBuilder stringBuilder1 = new StringBuilder();
StringBuilder stringBuilder2 = new StringBuilder();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "proc_UserBids";
sqlCommand.CommandTimeout = 1000;
string str = this.Page.Request.QueryString["name"] == null ? this.Page.Session["name"].ToString() : ((object)this.Page.Request.QueryString["name"]).ToString();
if (!(str == ""))
{
//Do Something
}
}
我得到的错误是:
异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。
string str = this.Page.Request.QueryString["name"] == null ? this.Page.Session["name"].ToString() : ((object)this.Page.Request.QueryString["name"]).ToString();