DataList的3层架构

来源:百度知道 编辑:UC知道 时间:2024/06/05 18:54:17
问题大概就是,我要做个留言板,用到DataList显示出来,但我只会在Datalist中给要显示的项在HTML里进行数据绑定,如果要用三层架构,要用到实体的时候该怎么做呢

在数据层调用数据库查询出要的内容,返回到业务层,再返回到页面层,返回的这个东西就是DataList的数据源,然后再进行对应的绑定就可以了!
例如,页面层可以这样写:
List<M_Product> listproduct = new List<M_Product>();
listproduct = BLL_Product.ReadNewProduct();//调用业务层返回的集合
this.DataList_FrontPage.DataKeyNames = new string[] { "col_id" };//得到datalist上网主键
this.DataList_FrontPage.DataSource = listproduct;//获取数据源
this.DataList_FrontPage.DataBind();//进行绑定

实体,数据,呵呵。用ORM就明白很多了。