zoukankan
html css js c++ java
Repeater也能多行多列显示数据!! joe
刚在用到显示数据时,不想用到gridview,因为那个复杂了,就想简单点的就好, 就想到用repeater
但是当我一用时,有一个不娞,它不能多行显示数据,
后面在网上查了一下,找到,这个方法很妙,拿出来给大家分享一下!!
<
asp:Repeater runat
=
"
server
"
id
=
"
repeater1
"
OnItemDataBound
=
"
Repeater1_ItemDataBound
"
>
<
HeaderTemplate
>
<
table width
=
"
100%
"
border
=
0
align
=
"
center
"
><
tr
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
td
><%
#Eval(
"
数据
"
)
%></
td
>
</
ItemTemplate
>
<
FooterTemplate
>
</
tr
></
table
>
</
FooterTemplate
>
</
asp:Repeater
>
.Cs代码
protected
int
i
=
1
;
protected
void
Repeater1_ItemDataBound(
object
src,RepeaterItemEventArgs e)
...
{
if
(i
%
3
==
0
)
...
{
e.Item.Controls.Add(
new
LiteralControl(
"
</tr><tr>
"
));
}
i
++
;
}
其中literalcontrol 是 一个相当于httpencode的类, 就原样输出html字符,不加处理!!!
用全局变量i来控制绑定多少行!!
很是妙焉!!
查看全文
相关阅读:
学习 TList 类的实现[1]
Dll 使用 PChar 参数的小例子
学习使用资源文件[11]
【转载】OGRE 内存管理
【转载】Ogre的内存分配策略
【转载】.NET面试题系列[0]
【转载】深入探讨透视投影坐标变换
【转载】四元数-Quaterion
【转载】齐次坐标
【转载】深入研究Windows内部原理绝对经典的资料
原文地址:https://www.cnblogs.com/CWater/p/1204353.html
最新文章
mapreduce (二) MapReduce实现倒排索引(一) combiner是把同一个机器上的多个map的结果先聚合一次
nutch fetcher.server.delay
nutch Fetcer阶段详解
短信验证码大概流程
操作dom影响性能的原因
window.requestAnimationFrame()
DocumentFragment对象
浅谈Websocket、Ajax轮询和长连接(long pull)
如何预览Github上的页面
HTML5+NodeJs实现WebSocket即时通讯
热门文章
setInterval 传值设参数
使用 JavaScript 将网站后台的数据变化实时更新到前端
SSE:服务器发送事件,使用长链接进行通讯
学习 TList 类的实现[8]
学习 TList 类的实现[7]
学习 TList 类的实现[6]
学习 TList 类的实现[5]
学习 TList 类的实现[4]
学习 TList 类的实现[3]
学习 TList 类的实现[2]
Copyright © 2011-2022 走看看