Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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 web用户控件_C#_Asp.net_User Controls - Fatal编程技术网

C# 带循环的asp.net web用户控件

C# 带循环的asp.net web用户控件,c#,asp.net,user-controls,C#,Asp.net,User Controls,我对webforms用户控件完全陌生,对于如何创建用户控件并在其上填充一些数据,我有点困惑 for(int i = 0; i < Price.EpList.Count(); i++) { Price.EpList[i].Amount.ToString(); Price.EpList[i].Code.ToString();

我对webforms用户控件完全陌生,对于如何创建用户控件并在其上填充一些数据,我有点困惑

for(int i = 0; i < Price.EpList.Count(); i++)
                        {

                            Price.EpList[i].Amount.ToString();
                            Price.EpList[i].Code.ToString();
                            Price.EpList[i].Desc.ToString();
                            Price.EpList[i].ID.ToString();

                        }
for(int i=0;i

EpList是一个列表,其中包含我希望以表格格式在网页中显示的信息,每行带有复选框。

查看中继器控件。您不必在列表中循环,只需将列表绑定到repeater,并为每个重复项定义所需的html模板


编辑:那篇文章使用Visual Basic,下面是C#翻译:

假设该中继器:

<asp:Repeater runat="server" ID="uxEpList">
<ItemTemplate>
<%--Html goes here--%>
<%# Eval("Amount")%>
<%# Eval("Code")%>
<%# Eval("Desc")%>
<%# Eval("ID")%>   
</ItemTemplate>
</asp:Repeater>

如果需要在另一个中继器中嵌套一个中继器(使用注释中的Desc属性),可以这样做,方法是声明性地设置DataSource属性(注意单引号):


//等等。。。

查看中继器控件。您不必在列表中循环,只需将列表绑定到repeater,并为每个重复项定义所需的html模板


编辑:那篇文章使用Visual Basic,下面是C#翻译:

假设该中继器:

<asp:Repeater runat="server" ID="uxEpList">
<ItemTemplate>
<%--Html goes here--%>
<%# Eval("Amount")%>
<%# Eval("Code")%>
<%# Eval("Desc")%>
<%# Eval("ID")%>   
</ItemTemplate>
</asp:Repeater>

如果需要在另一个中继器中嵌套一个中继器(使用注释中的Desc属性),可以这样做,方法是声明性地设置DataSource属性(注意单引号):


//等等。。。

您在哪里调用此示例?您在哪里调用此示例?感谢您的帮助,我忘记提到价格。EpList[i].Desc[j].Item;Price.EpList[i].Desc[j].ID;Price.EpList[i].Desc[j].单位:;EpList中有嵌套列表如何在Repeater中显示您也可以嵌套Repeater。我会用一个例子来更新代码。我不知道你说的是什么意思。您正在尝试使用嵌套中继器的DataSource属性获取数据吗?它装订正确吗?最好开始一个新问题,这样您就可以发布新代码了。谢谢您的帮助,我忘了提到Price.EpList[i].Desc[j].Item;Price.EpList[i].Desc[j].ID;Price.EpList[i].Desc[j].单位:;EpList中有嵌套列表如何在Repeater中显示您也可以嵌套Repeater。我会用一个例子来更新代码。我不知道你说的是什么意思。您正在尝试使用嵌套中继器的DataSource属性获取数据吗?它装订正确吗?最好开始一个新问题,这样您就可以发布新代码了。
<asp:Repeater runat="server" ID="uxEpList">
<ItemTemplate>
    <asp:Repeater Datasource='<%# Eval("Desc")%>' runat="server">
    <ItemTemplate>
    //etc...