gpt4 book ai didi

来自 2 个 StringCollections 的 C# Repeater.DataSource

转载 作者:太空宇宙 更新时间:2023-11-03 17:47:24 24 4
gpt4 key购买 nike

我有 2 个 StringCollections:

StringCollection ParameterIDs
StringCollection ParameterValues

是否能够将这两个 StringCollections 映射为 DataSource,例如:

repeater.DataSource = ParameterIDs (as row1) + ParameterValues (as row2);
repeater.DataBind();

并在中继器中使用它们,例如:

                <asp:Repeater ID="repeatParameters" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="formLabel">
<asp:Label ID="lblParameterID" Text="<% #DataBinder.Eval(Container.DataItem,"ParameterIDs") %>" runat="server" MaxLength="50"></asp:Label><br />
</td>
<td class="formInputText">
<asp:Label ID="lblParameterValue" Text="<%#DataBinder.Eval(Container.DataItem,"ParameterValues") %>" runat="server" MaxLength="50"></asp:Label><br />
</td>
</tr>
<tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

最佳答案

第一个想法:
将它们混合成 Dictionary并将其用作数据源。

第二个想法:
创建 DataSet与你需要的值(value)观。

第三个想法:
使用 KeyValuePair .

如您所见,有很多不同的方法可以做到这一点,但它们都有一个共同的元素:
创建一个存储和映射相应值的对象。

关于来自 2 个 StringCollections 的 C# Repeater.DataSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1064613/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com