.NET三层架构中,表示层中的DetailsView控件,如何绑定BLL层传来的Students实体类的对象?
表示层中,有一个DetailsView控件,此页面的后台程序中:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["code"] != null)
{
int code = int.Parse(Request.QueryString["code"].ToString());
Students stu = StudentsBLL.GetStudentsByCode(code);
this.DetailsView1.DataSource= stu;
this.DetailsView1.DataBind();
}
}
意思很简单,即:得到传来的 code的数值,调用StudentsBLL的GetStudentsByCode(code)方法,此方法传来一个Students对象,此Students对象包含name,age 等属性。现在需要在页面中,显示此Students对象的name,age 等属性。
但是,这样的绑定,有错误。
不知道,这样,该如何解决呢?
非常谢谢大家,不知道是否说明白了。
表示层中,有一个DetailsView控件,此页面的后台程序中:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["code"] != null)
{
int code = int.Parse(Request.QueryString["code"].ToString());
Students stu = StudentsBLL.GetStudentsByCode(code);
this.DetailsView1.DataSource= stu;
this.DetailsView1.DataBind();
}
}
意思很简单,即:得到传来的 code的数值,调用StudentsBLL的GetStudentsByCode(code)方法,此方法传来一个Students对象,此Students对象包含name,age 等属性。现在需要在页面中,显示此Students对象的name,age 等属性。
但是,这样的绑定,有错误。
不知道,这样,该如何解决呢?
非常谢谢大家,不知道是否说明白了。
解决方案 »
- 急求ASP.net Ajax2.0安装包 哪位帮忙传一个 CSDN下载需要3积分
- 类型"System.Int64"的对象无法转换为类型"System.String"
- 跪求 此网站的报价
- C#写新闻小偷的思路...........
- 奇怪现象 服务器控件显示出错!怎么解决?
- 50分求CSS小问题.请高手指点.一定给分.
- 关于Regex.Split的问题(正则表达)
- 难度问题:如何用代码(根据条件而不是事件)自动刷新本页面?
- datagrid问题
- 如何获得鼠标的位置
- 学的是asp,现在想学asp.net,但是很多人说C#比VB.NET好,我究竟该如何选择啊?
- 运行页面居然无法显示页面~!具体内容请进
s.add(stu)
this.DetailsView1.DataSource= s;
this.DetailsView1.DataBind(); 或不要放DetailsView,
放几个Label
Label.Text = stu.name;