ProductsManage bll = new ProductsManage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Products model = (Products)bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));
            this.title.InnerHtml = model.Title;
            this.content.InnerHtml = model.Content;
        }
    }
错误 2 无法将类型“yc.Model.Products”转换为“Products” C:\Documents and Settings\Administrator\桌面\宇晨网站区\宇晨2\yc2\yc\Product.aspx.cs 21 30 C:\...\yc\
错误 3 “Products”并不包含“Content”的定义 C:\Documents and Settings\Administrator\桌面\宇晨网站区\宇晨2\yc2\yc\Product.aspx.cs 23 44 C:\...\yc\

解决方案 »

  1.   

    (Products)bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));
    这个错了,你返回的是什么类型
      

  2.   

    看看GetProductById返回的类型是不是Products 呗
      

  3.   

    返回的就是Products啊,问题就错在这里,我都晕了
      

  4.   

    1.如果GetProductById方法返回的是Products,那么不需要转换
    2.是不是Model层做了修改没生成?
      

  5.   

    yc.Model.Products和Products可能不一样,检查Products的命名空间,以及yc.Model.Products是如何来的
      

  6.   

    Products model = bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));
      

  7.   

    鼠标放在Products上,看看命名空间是否与yc.Model.Products一致
      

  8.   


    ProductsManage bll = new ProductsManage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Products model = bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));
                this.title.InnerHtml = model.Title;
                this.content.InnerHtml = model.Content;
        }
    }
      

  9.   

    Products,是不是项目里有重名?
    既然返回是对的,为什么要强转
      

  10.   

    我是看当时报无法隐转就试着显转 /// <summary>
            /// 获得一条产品记录
            /// </summary>
            /// <param name="id">记录ID</param>
            /// <returns>products</returns>
            public yc.Model.Products GetProductById(int id)
            {
                DataTable dt = dal.GetProduct(id);
               yc.Model.Products model = null;
                if (dt != null)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        model = new Products();
                        model.Title = row["title"].ToString();
                        model.Content = row["content"].ToString();
                    }
                }
                return model;
            }
    using System;
    using System.Collections.Generic;
    using System.Text;
    using yc.Model;
    using yc.DAL;
    using System.Data;namespace yc.BLL
    {
        /// <summary>
        /// 产品业务类
        /// </summary>
        public class ProductsManage
        {
      

  11.   

    GetProductById 这方法贴出来
      

  12.   

    yc.Model.Products model = bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));
      

  13.   

    行了。项目里我找了没有重命的,可是他硬是报了重命的错误。不晓的怎么回事,我用yc.Model.Products model = bll.GetProductById(Convert.ToInt32(Request.QueryString["id"]));解决了。。搞不清楚到底哪出了问题。