我一直在 vb.net 中使用中继器并且对它们没有任何问题,但是我正在处理一些 c# 并且无法进行转换(并且在线转换作业似乎不起作用)
我的中继器设置如下:
<asp:Repeater runat="server" ID="rptItems">
<ItemTemplate>
<div class="span12 grey-box">
<div class="hero-block3">
<div class="row show-grid">
<div class="span9">
<div class="hero-content-3">
<h2><asp:Literal ID="ltrName" runat="server"></asp:Literal></h2>
<p><asp:Literal ID="ltrDescription" runat="server"></asp:Literal></p>
</div>
</div>
<div class="span3">
<div class="tour-btn">
<small>How Many?<br /></small>
<asp:TextBox runat="server" ID="tbox" Width="40"></asp:TextBox>
</div>
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
这就是我在 vb.net 中正常填充它的方式
Private Sub rptItems_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptClientList.ItemDataBound
Dim nRow As DataRowView = Nothing
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
With e.Item
nRow = DirectCast(e.Item.DataItem, DataRowView)
With DirectCast(.FindControl("ltrText"), Literal)
.Text = nRow("Description")
End With
With DirectCast(.FindControl("ltrTitle"), Literal)
.Text = nRow("Name")
End With
End With
End Select
End Sub