ASP.Net中的关于数据绑定
2012-04-16 09:50
357 查看
1. 绑定标签 <%# …… %> 可绑定标签属性值,表达式,方法的结果及数据源等。
a. 绑定属性之label的Text属性值 :
<asp: label1 ID="labtxt" Text="<%# DataTime.Now.ToShortString() %>" >
this.label1.DataBind();***************后台代码千万不能少
b.绑定变量
后台代码类中定义一变量 protected Color bgcolor=Color.FromArgb(180,140,210);
前台 <asp: label1 ID="labtxt" BackColor="<%# bgcolor %>" runat="server">
this.labtxt.DataBind();
c.绑定常量
后台 protected int a=15;
protected int b=10;
<td> a+b=<%# a+b %> <td>
this.DataBind();
d.绑定 方法
在后面写个方法 protected string GetDate(){……}
在前台 <td> 今天:<%# GetData() %> </td>
this.DataBind();
e.绑定 数组集合
Protected string[] strarray={"acb","def","xyz"};
< asp: DropDownList DataSource="<%# strarray %>" >
this.DataBind();
a. 绑定属性之label的Text属性值 :
<asp: label1 ID="labtxt" Text="<%# DataTime.Now.ToShortString() %>" >
this.label1.DataBind();***************后台代码千万不能少
b.绑定变量
后台代码类中定义一变量 protected Color bgcolor=Color.FromArgb(180,140,210);
前台 <asp: label1 ID="labtxt" BackColor="<%# bgcolor %>" runat="server">
this.labtxt.DataBind();
c.绑定常量
后台 protected int a=15;
protected int b=10;
<td> a+b=<%# a+b %> <td>
this.DataBind();
d.绑定 方法
在后面写个方法 protected string GetDate(){……}
在前台 <td> 今天:<%# GetData() %> </td>
this.DataBind();
e.绑定 数组集合
Protected string[] strarray={"acb","def","xyz"};
< asp: DropDownList DataSource="<%# strarray %>" >
this.DataBind();
相关文章推荐
- 关于ASP.net MVC 中DropDownList绑定与提交数据
- 关于ASP.NET 数据绑定
- 目前发现的VS2005 asp.net 数据绑定bug (二) -关于ObjectDatasource 和TableAdapter
- 关于使用asp.net 的分页显示数据。Repeater绑定数据后的分页显示。
- ASP.NET 关于Eval绑定数据的时间格式
- 关于ASP.NET的数据绑定
- 关于Asp.Net 服务器控件OnClientClick属性数据绑定
- asp.net 2.0的GridView的动态绑定数据的用法!
- ASP.net:三层Web体系结构里的两种数据绑定模式
- ASP.NET 2.0 中实现模板中的数据绑定系列(2)
- asp.net 2.0教程 数据绑定控件
- 深入ASP.NET数据绑定
- ASP.NET数据绑定控件详解
- ASP.NET 2.0的几种数据源和数据绑定控件
- asp.net下的“Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用。”错误的一个可能的成因
- ASP.NET之GridView数据绑定
- [导入]ASP.net的数据在绑定
- ASP.NET MVC中 Jquery AJAX 获取数据利用MVC模型绑定实现输出
- ASP.NET - 绑定数据-三元
- ASP.NET数据绑定菜单控件