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\
这个错了,你返回的是什么类型
2.是不是Model层做了修改没生成?
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;
}
}
既然返回是对的,为什么要强转
/// 获得一条产品记录
/// </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
{