问题描述
我实际上很想在GridView上有一个AlternatingItemTemplate,但是它提供的只是一个AlternatingItemStyle.在我的网格中,每两列(在表布局中)行在第一列中有一个图像,在第二列中有一个描述.我希望图像的位置和描述在交替的行上交替显示.
I would actually love to have an AlternatingItemTemplate on a GridView, but all it offers is an AlternatingItemStyle. In my grid, each two column row (in a table layout), has an image in the first column, and a description in the second column. I would like to have the positioning of the image and description alternate on alternate rows.
我该怎么做?
推荐答案
您可能会考虑使用AlternatingItemStyle对此进行管理.
You might consider managing this with AlternatingItemStyle for fun.
使用1列或中继器:
项目模板:
<div class="MyImage"><img src="" /></div>
<div class="MyDescription">Blah...Blah...</div>
CSS:
.MyItemStyle .MyImage {width:49%; float:left;}
.MyItemStyle .MyDescription {width:49%; float:right;}
.MyAltItemStyle .MyImage {width:49%; float:right;}
.MyAltItemStyle .MyDescription {width:49%; float:left;}
应用于Gridview/Repeater:
Apply to Gridview/Repeater:
ItemStyle = "MyItemStyle"
AlternatingItemStyle = "MyAltItemStyle"
这将使您改变主意,而不必重新编写事件处理程序等.
This would let you change your mind without having to recode event handlers etc.
这篇关于交替项样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!