Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.net中使用repeater的有序列表_C#_Asp.net - Fatal编程技术网

C# ASP.net中使用repeater的有序列表

C# ASP.net中使用repeater的有序列表,c#,asp.net,C#,Asp.net,下面的代码不断给我一个错误: .ASPX文件中的转发器代码 <asp:Repeater ID="rptDescription" runat="server"> <HeaderTemplate><ol class="DescriptionRepeater"></HeaderTemplate> <ItemTemplate> <li> <

下面的代码不断给我一个错误:

.ASPX文件中的转发器代码

<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