日期:2014-05-18  浏览次数:20515 次

问题请教.请指点
[NullReferenceException:   未将对象引用设置到对象的实例。]
      Manage_AddProduct_Question.BindddlProduct()   in   e:\vss\AocLife\Source\prototype\AocLife\AocLife\Manage\AddProduct_Question.aspx.cs:36
      Manage_AddProduct_Question.Page_Load(Object   sender,   EventArgs   e)   in   e:\vss\AocLife\Source\prototype\AocLife\AocLife\Manage\AddProduct_Question.aspx.cs:22
      System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr   fp,   Object   o,   Object   t,   EventArgs   e)   +15
      System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object   sender,   EventArgs   e)   +34
      System.Web.UI.Control.OnLoad(EventArgs   e)   +99
      System.Web.UI.Control.LoadRecursive()   +47
      System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint,   Boolean   includeStagesAfterAsyncPoint)   +106


  protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                Power.Judge(this);
                if   (!IsPostBack)
                {
                        BindddlProduct();
                        bindQuestion(Convert.ToInt32(ddlProduct.SelectedValue));
                }
        }
        private   void   BindddlProduct()
        {
                ProductBL   ProductBL   =   new   ProductBL();
                SqlDataReader   dr   =   ProductBL.SelectProduct();
                ddlProduct.DataSource   =   dr;
                ddlProduct.DataTextField   =   "ProductName ";
                ddlProduct.DataValueField   =   "ProductKey ";
                ddlProduct.DataBind();
                dr.Close();

                ddlProduct.Items.FindByValue(GetProductKey().ToString()).Selected=true;   这句话报错
        }

        private   void   bindQuestion(int   ProductKey)
        {
                QuestionBL   questionBL   =   new   QuestionBL();
                SqlDataReader   sdr   =   questionBL.NotinProductQuestion(ProductKey);
                ddlQuestion.DataSource   =   sdr;
                ddlQuestion.DataTextField   =   "Title ";
                ddlQuestion.DataValue