C# ASP.net中使用repeater的有序列表
下面的代码不断给我一个错误: .ASPX文件中的转发器代码C# ASP.net中使用repeater的有序列表,c#,asp.net,C#,Asp.net,下面的代码不断给我一个错误: .ASPX文件中的转发器代码 <asp:Repeater ID="rptDescription" runat="server"> <HeaderTemplate><ol class="DescriptionRepeater"></HeaderTemplate> <ItemTemplate> <li> <
<asp:Repeater ID="rptDescription" runat="server">
<HeaderTemplate><ol class="DescriptionRepeater"></HeaderTemplate>
<ItemTemplate>
<li>
<a href="#"><%= this %></a>
</li>
</ItemTemplate>
<FooterTemplate><ol/></FooterTemplate>
</asp:Repeater>
用于在.ASPX.CS文件中填充中继器的代码
im使用visual studio 2017该代码导致有序列表中填充.aspx文件的路径
List<string> lstDescription = new List<string>();
lstDescription.Add("this is the first description");
lstDescription.Add("this is the second description");
rptDescription.DataSource = lstDescription;
rptDescription.DataBind();
List lstDescription=新列表();
lstDescription.Add(“这是第一个描述”);
lstDescription.Add(“这是第二个描述”);
rptDescription.DataSource=lstDescription;
rptDescription.DataBind();
这不是一个实际的场景。无论如何,您只需使用Container.DataItem
,因为DataItem
本身就是一个字符串。请确保使用绑定语法
而不是
这不是一个实际情况。无论如何,您只需使用Container.DataItem
,因为DataItem
本身就是一个字符串。请确保使用绑定语法
而不是
您需要使用
而不是
此
将引用当前上下文,通常是当前页面。您需要使用
而不是
<代码>此
将引用通常为当前页面的当前上下文。
<asp:Repeater ID="rptDescription" runat="server">
<HeaderTemplate>
<ol class="DescriptionRepeater">
</HeaderTemplate>
<ItemTemplate>
<li>
<a href="#"><%# Container.DataItem %></a>
</li>
</ItemTemplate>
<FooterTemplate>
<ol />
</FooterTemplate>
</asp:Repeater