zoukankan
html css js c++ java
如何使用 DataBinder.Eval(Container.DataItem,"num","{0:p}") 对DataList 进行数据绑定
如何使用 DataBinder.Eval(Container.DataItem,"num","{0:p}") 对DataList 进行数据绑定
前台页面代码:
1
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
DataContainer.aspx.cs
"
Inherits
=
"
test_DataBind_DataContainer
"
%>
2
<%
@ Import Namespace
=
"
System.Data
"
%>
3
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
4
5
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
6
<
head
runat
="server"
>
7
<
title
>
无标题页
</
title
>
8
</
head
>
9
<
body
>
10
<
form
id
="form1"
runat
="server"
>
11
<
div
>
12
<
asp:DataList
ID
="DataList1"
runat
="server"
>
13
<
ItemTemplate
>
14
数字:
<%
# ((DataRowView)Container.DataItem)[
"
num
"
]
%>
15
平方:
<%
# (
int
)((DataRowView)Container.DataItem)[
"
num
"
]
*
(
int
)((DataRowView)Container.DataItem)[
"
num
"
]
%>
16
货币:
<%
# DataBinder.Eval(Container.DataItem,
"
num
"
,
"
{0:p}
"
)
%>
17
</
ItemTemplate
>
18
</
asp:DataList
></
div
>
19
</
form
>
20
</
body
>
21
</
html
>
22
后台页面代码:
1
using
System;
2
using
System.Data;
3
using
System.Configuration;
4
using
System.Collections;
5
using
System.Web;
6
using
System.Web.Security;
7
using
System.Web.UI;
8
using
System.Web.UI.WebControls;
9
using
System.Web.UI.WebControls.WebParts;
10
using
System.Web.UI.HtmlControls;
11
12
public
partial
class
test_DataBind_DataContainer : System.Web.UI.Page
13
{
14
protected
void
Page_Load(
object
sender, EventArgs e)
15
{
16
if
(
!
this
.IsPostBack)
17
{
18
DataTable dt
=
new
DataTable();
//
先定义一个数据表对象.
19
dt.Columns.Add(
"
num
"
,
typeof
(
int
));
//
添加列 参数:字段名称,数据类型
20
for
(
int
i
=
0
; i
<
10
;i
++
)
21
{
22
DataRow dr
=
dt.NewRow();
//
添加行,注意写法: dt.NewRow();
23
dr[
0
]
=
i;
24
dt.Rows.Add(dr);
//
将行添加到项目中.
25
}
26
this
.DataList1.DataSource
=
dt;
27
this
.DataList1.DataBind();
28
}
29
}
30
}
31
查看全文
相关阅读:
golang闭包,传统斐波那契
ubuntu 软件桌面图标创建
Mysql系列-性能优化神器EXPLAIN使用介绍及分析
Sklearn-GridSearchCV网格搜索
sklearn逻辑回归(Logistic Regression)类库总结
scikit-learn模块学习笔记(数据预处理模块preprocessing)
Python中的高级数据结构
Python进阶之“属性(property)”详解
python模块之itertools
python list有关remove的问题
原文地址:https://www.cnblogs.com/gfwei/p/538966.html
最新文章
MySQL之爱之初体验
nginx 499 错误码
PHP 二维数组去重方法
PHP中的src32
BOM问题
中国赚钱的方式彻底变了,再不懂就晚了!(转)
JAVA生成word优缺点对比
(转)React几种基本配置方案
ECMAScript 6 引入的 JavaScript 类(class)--类同java class
Arrow Functions
热门文章
什麼是Docker?
Google宣布对其域名启用HSTS协议(转)
golang 获取statuscode
golang 字符串替换截取
golang struct里面的字段,或者slice排序
golang interface
golang单点推送
递归调用
golang 随机数/域名校验
linux ssh文件输
Copyright © 2011-2022 走看看