zoukankan
html css js c++ java
对 Repeater 进行绑定 使用 DataBinder.Eval(Container.DataItem,"personname")
使用 DataBinder.Eval(Container.DataItem,"personname") 对 Repeater 进行绑定
及介绍Repeater 5个模板的使用
前台页面代码:
1
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
repeatrControl.aspx.cs
"
Inherits
=
"
test_DataBind_repeatrControl
"
%>
2
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:Repeater
ID
="Repeater1"
runat
="server"
>
13
<
AlternatingItemTemplate
>
14
<
font
color
="blue"
>
15
<%
# DataBinder.Eval(Container.DataItem,
"
personname
"
)
%>
16
<%
# DataBinder.Eval(Container.DataItem,
"
personsex
"
)
%>
17
</
font
><
br
/>
18
</
AlternatingItemTemplate
>
19
<
FooterTemplate
>
20
<
h3
>
页尾
</
h3
>
21
</
FooterTemplate
>
22
<
HeaderTemplate
>
23
<
h3
>
页头
</
h3
>
24
</
HeaderTemplate
>
25
<
ItemTemplate
>
26
<%
# DataBinder.Eval(Container.DataItem,
"
personname
"
)
%>
27
<%
# DataBinder.Eval(Container.DataItem,
"
personsex
"
)
%>
28
<
br
/>
29
</
ItemTemplate
>
30
<
SeparatorTemplate
>
31
<
hr
Size
="1"
Color
="blue"
/>
32
</
SeparatorTemplate
>
33
</
asp:Repeater
>
34
35
</
div
>
36
</
form
>
37
</
body
>
38
</
html
>
39
后台代码:
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
using
System.Data.SqlClient;
12
public
partial
class
test_DataBind_repeatrControl : System.Web.UI.Page
13
{
14
protected
void
Page_Load(
object
sender, EventArgs e)
15
{
16
if
(
!
this
.IsPostBack)
17
{
18
SqlConnection con
=
DBtest.createCon();
19
SqlDataAdapter sdr
=
new
SqlDataAdapter();
20
sdr.SelectCommand
=
new
SqlCommand(
"
select * from person
"
,con);
21
DataSet ds
=
new
DataSet();
22
sdr.Fill(ds,
"
emp
"
);
//
用数据适配器填充数据集.
23
this
.Repeater1.DataSource
=
ds;
24
this
.Repeater1.DataBind();
25
26
}
27
}
28
}
29
查看全文
相关阅读:
接口测试-postman
select
SQLserver的七种约束。
数据库的创建、表的创建。
vim编辑器删除键失效
客户端通过 HTTP 请求的 Header 信息总结
清理/boot目录内容
CentOS 7 配置samba 和 autofs
CentOS 7 配置 nfs 和 autofs
tftp简单文件传输协议基本配置
原文地址:https://www.cnblogs.com/gfwei/p/538959.html
最新文章
Vue + Element UI 实现权限管理系统 前端篇(十):动态加载菜单
Vue + Element UI 实现权限管理系统 前端篇(十一):第三方图标库
Vue + Element UI 实现权限管理系统 前端篇(六):更换皮肤主题
Vue + Element UI 实现权限管理系统 前端篇(七):功能组件封装
Vue + Element UI 实现权限管理系统 前端篇(八):管理应用状态
412记一次zuul处理重定向问题
4月12记一次上传文件异常
lombok简单使用
hystrix-dashborad监控仪表盘简单配置
eureka简单使用
热门文章
修改源码,解决security标签库找不到ioc容器问题
security-test01-给请求路径配置权限
当存在多个ioc容器的项目中使用security框架的问题
29security带盐值加密
26-spring security csrf防止跨站请求伪造
:
软件测试基础问答
初识fiddler
测试沙箱实战
如何做接口测试。
Copyright © 2011-2022 走看看