当前位置: 代码迷 >> Web Service >> Repeater的有关问题
  详细解决方案

Repeater的有关问题

热度:318   发布时间:2012-01-23 21:57:28.0
Repeater的问题
C# code

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                    <ItemTemplate>
                        <div class='<%# Container.ItemIndex% 4 == 0?"gray":  "white" %>'>
                            <table width="220px"  cellpadding="0" cellspacing="0">
                                <tr>
                                        <td >
                                                    xxx
                                        </td>
                    </ItemTemplate>
                    <AlternatingItemTemplate>
                                        <td >
                                                    xxx
                                        </td>
                                </tr>
                            </table>
                        </div>
                    </AlternatingItemTemplate>
                </asp:Repeater>


代码如上,我的想法是利用ItemTemplate来控制一个表格开始,再用AlternatingItemTemplate来控制结束,但是如果只有奇数条数据。则div和tr无法闭合。。。。求高人指点。
备注:其他控件也许可以满足要求,但是个人觉得没有repeater自由。所以求高人指点。。。。。。
目的:数据体现方式为一行两条数据,行与行之间有背景颜色区分

------解决方案--------------------
可以考虑在生成数据时,检查有多少行,如果是单数,加一个空行
  相关解决方案