本文介绍了ERROR MESSAGE ------- system.window.documents.listitem不包含带有2个参数的构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 private void Wash_Iron_Load(对象发​​件人,EventArgs e) { obj = new WashManagement.WashIron(Constant.laundry_db); LoadCategory(cmbitem1); } private void LoadCategory(ComboBox CboCategory) { IDataReader drCategory; drCategory = obj.GetCategoryName(); while (drCategory.Read()) { CboCategory.Items.Add( new ListItem(drCategory [ product_category_name]。ToString(),drCategory [ product_category_no]。ToString())); // --------->错误消息 } public IDataReader GetCategoryName() { try { DbCommand com = db.GetStoredProcCommand(USP_Get_Category); return db.ExecuteReader(com); } catch (例外) { throw ; } } // 获取产品类别 private const string USP_Get_Category = USP_Get_Category; 错误信息 ---------------- 系统.window.documents.listitem不包含带有2个参数的构造函数解决方案 查看错误消息: system.window.documents.listitem不包含带2个参数的构造函数 它没有:http://msdn.microsoft.com/en-us/library/system .windows.documents.listitem.listitem%28v = vs.85%29.aspx [ ^ ] System.Web.UI.WebControls.ListItem执行: http://msdn.microsoft.com/en-GB/library/system.web.ui.webcontrols.listitem.aspx [ ^ ] 我怀疑你有一个system.window.documents的using语句,你不需要,或者你需要在构造时完全限定你的ListItem它 private void Wash_Iron_Load(object sender, EventArgs e){obj = new WashManagement.WashIron(Constant.laundry_db);LoadCategory(cmbitem1);} private void LoadCategory(ComboBox CboCategory){IDataReader drCategory;drCategory = obj.GetCategoryName();while (drCategory.Read()){CboCategory.Items.Add(new ListItem(drCategory["product_category_name"].ToString(), drCategory["product_category_no"].ToString())); //---------> ERROR MESSAGE } public IDataReader GetCategoryName(){try{DbCommand com = db.GetStoredProcCommand(USP_Get_Category);return db.ExecuteReader(com);}catch (Exception){throw;}} //GET PRODUCT CATEGORYprivate const string USP_Get_Category = "USP_Get_Category";ERROR MESSAGE---------------- system.window.documents.listitem does not contain a constructor that takes 2 arguments 解决方案 Look at the error message: system.window.documents.listitem does not contain a constructor that takes 2 argumentsIt doesn''t: http://msdn.microsoft.com/en-us/library/system.windows.documents.listitem.listitem%28v=vs.85%29.aspx[^] The System.Web.UI.WebControls.ListItem does:http://msdn.microsoft.com/en-GB/library/system.web.ui.webcontrols.listitem.aspx[^]I suspect you have a using statement for system.window.documents which either you do not need, or which means you need to fully qualify your ListItem when you construct it. 这篇关于ERROR MESSAGE ------- system.window.documents.listitem不包含带有2个参数的构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-09 23:49