未将对象引用设置到对象的实例 求解
“/ShopWeb”应用程序中的服务器错误。
--------------------------------------------
未将对象引用设置到对象的实例。  
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  
异常详细信息: 
System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:  
行 41:                 pd = BLLFactory.CreateProductBLL().GetProdByID(Request.QueryString["pid"].Trim());
行 42:                 txtID.Enabled = false;
行 43:                 txtID.Text = pd.ProdId;
行 44:                 txtName.Text = pd.ProdName;
行 45:                 ddlCategory.SelectedValue = pd.CategoryId;  
源文件: h:\web课上练习\下学期\案例\FlowerShop\ShopWeb\Admin\AddProduct.aspx.cs    行: 43  
堆栈跟踪:  
[NullReferenceException: 未将对象引用设置到对象的实例。]    Admin_AddProduct.Page_Load(Object sender, EventArgs e) in h:\web课上练习\下学期\案例\FlowerShop\ShopWeb\Admin\AddProduct.aspx.cs:43
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627  
------解决方案--------------------pd = BLLFactory.CreateProductBLL().GetProdByID(Request.QueryString["pid"].Trim());
查这句,返回结果为 null 了!
------解决方案--------------------pd = BLLFactory.CreateProductBLL().GetProdByID(Request.QueryString["pid"].Trim());这句获取的数据是空的,先把红色的部分去掉看下
------解决方案-------------------- pd = BLLFactory.CreateProductBLL().GetProdByID(Request.QueryString["pid"].Trim());
 这句有误,你应该先判断Request.QueryString["pid"]的值是否为NULL
Request.QueryString["pid"] 看看这个有值没?
------解决方案--------------------pd = BLLFactory.CreateProductBLL().GetProdByID(Request.QueryString["pid"].Trim());
首先肯定是Pd这个实例化的对象是null的问题了。
再看如果你封装的方法没问题的话,只能认为Request.QueryString["pid"].Trim() 这个值是null或者在数据库里对应的没有这个ID 的product。请确认下这3中情况就行 了