c# - 动态数据绑定(bind)到转发器或 Datalist 控件,按列

标签 c# asp.net .net visual-studio repeater

下面的 image/output 显示了数据应该如何rendered 考虑到表格的 rankID

enter image description here 还有下面的demo table

enter image description here

现在,它们将是 4 个不同的行,它们应该根据第一张幻灯片上的 RankID [1,2,3,4] 绑定(bind)到上面显示的图像然后在用户点击 next navigation 时继续播放幻灯片。

为了达到同样的目的,我们使用了Repeater 控件,但是data is bounded row wise 因此决定使用datalist 控件 具有按列绑定(bind)数据的属性,但我们仍然无法做到,否则我们需要使用多个或嵌套的 repeater/datalist 控件。

请提出解决方案或实现相同目标的方法..

最佳答案

您可以完全控制 Repeater Contents 来为第一项创建差异。请参阅下面的代码段。

<table border="1" cellspacing="0" cellpadding="3">
    <tr>
        <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>

                <%# Container.ItemIndex == 0 ? "<td colspan=\"3\">" : "<td>" %>

                <%# Eval("Description") %>

                <%# Container.ItemIndex == 0 ? "</td></tr><tr>" : "</td>" %>

            </ItemTemplate>
        </asp:Repeater>
    </tr>
</table>

关于c# - 动态数据绑定(bind)到转发器或 Datalist 控件,按列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50523952/

相关文章:

c# - C#函数执行时异步等待

c# - 国际奥委会 : CaSTLe Windsor and WebAPI

c# - Web API 通用操作

c# - mscorlib.dll : Access to the path . 中发生类型为 'System.UnauthorizedAccessException' 的未处理异常。被拒绝

c# - CS0053错误问题

c# - Sitecore 7 搜索所有内容

c# - 是否有使用属性的 .NET 参数验证标准框架?

c# - 事务存储过程 C#

c# - 使用 C# 的客户端 IP

c# - Visual Studio 多项目解决方案选项