asp.net错误 求帮忙Label3.Text = Session[ GoodsCity ].ToString();

public partial class _Default : System.Web.UI.Page{ Common com = new Common(); protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty((String)System.Web.HttpContext.Current.Session["GoodsCity"])) { Label3.Text = Session["GoodsCity"].ToString();//使用“new”关键字创建对象实力;在调用方法前通过检查确定对象是否为null } DataTable table = com.paihangProduct(Session["GoodsCity"].ToString()); if (table.Rows.Count != 0) { DataList1.DataSource = table; DataList1.DataBind(); } } protected void productdel(object source, DataListCommandEventArgs e) { if (e.CommandName == "describe") { string goodsid = e.CommandArgument.ToString(); Response.Redirect("productdescribe.aspx?GoodsID=" + goodsid); } }
2026年09月26日 15:54
有4个网友回答
网友(1):

Session["GoodsCity"]=…
你看看你程序中有没有这样的代码,
有问题联系我:QQ 九五611四三82

网友(2):

if (String.IsNullOrEmpty
你改成
if (!String.IsNullOrEmpty

你的Session["GoodsCity"]应该是null

网友(3):

if (String.IsNullOrEmpty((String)System.Web.HttpContext.Current.Session["GoodsCity"]))改为

if(Session["GoodsCity"]!=null&&!String.IsNullOrEmpty((String)Session["GoodsCity"])))

网友(4):

Session["GoodsCity"]是否有值啊~~~