gpt4 book ai didi

asp.net - 中继器控件中的项目顺序

转载 作者:行者123 更新时间:2023-12-01 08:25:55 34 4
gpt4 key购买 nike

是否可以在运行时对转发器控件中的行重新排序。例如:如果我有中继器控制,如下所示。如果我必须在运行时更改项目模板中表的行顺序怎么办?就像我需要根据定义的顺序在第一行显示特殊要求,然后在第二行显示好处,然后在第三行显示偏好。我知道我可以通过让它成为动态中继器来做到这一点。但是还有别的办法吗?

 <asp:Repeater ID="repGuestInformation" ClientIDMode="AutoID" runat="server" OnItemDataBound="repGuestInformation_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<asp:Repeater ID="repGuestEventInformation" runat="server" OnItemDataBound="repGuestEventInformation_ItemDataBound">
<%-- <HeaderTemplate>


</HeaderTemplate>--%>
<ItemTemplate>
<tr>
<td>Registrants</td>
<td></td>
<td><asp:Label ID="lblCost" runat="server" Text="Cost" /></td>
<td></td>
</tr>
<tr>
<td valign="top">
<asp:Literal ID="ltlRegistrant" runat="server" />
<asp:DropDownList ID="ddlGuest" runat="server" OnSelectedIndexChanged="ddlGuest_SelectedIndexChanged" AutoPostBack="true" />
<asp:HiddenField ID="hfRegistrantName" runat="server" />
</td>
<td>
<table>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr>
<td>
<%-- Benefits --%>
<asp:Label ID="lblConstituentBenefits" runat="server" Text="Benefits" ></asp:Label>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<asp:CheckBoxList ID="chkBoxListRegistrantBenefits" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="chkBoxListRegistrantBenefits_SelectedIndexChanged" >
</asp:CheckBoxList>
</td>
<td></td>
</tr>
<tr>
<td>
<%-- Preference--%>
<asp:Label ID="lblConstituentPreference" runat="server" Text="Preference" ></asp:Label>
</td>
<td></td>
<td></td>
</tr>
<asp:Repeater ID="repEventPreference" runat="server" OnItemDataBound="repEventPreference_ItemDataBound">
<ItemTemplate>
<tr>
<td></td>
<td>
<asp:Literal ID="ltlEventPreference" runat="server" />
<asp:HiddenField ID="hfID" runat="server" />
</td>
<td>
<asp:DropDownList ID="ddlEventPreference" runat="server" AppendDataBoundItems="true"
AutoPostBack="true" OnSelectedIndexChanged="ddlEventPreference_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td>
<%-- Special Requests--%>
<asp:Label ID="lblConstituentSpecialRequest" runat="server" Text="Special Requests" ></asp:Label>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<asp:CheckBoxList ID="chkBoxListSR" runat="server" AutoPostBack="true" OnSelectedIndexChanged="chkBoxListSR_SelectedIndexChanged">
</asp:CheckBoxList>
</td>
<td></td>
</tr>
<tr>
<td>
<asp:Panel ID="registrantAttPanel" runat="server" />
</td>
<td></td>
<td></td>
</tr>
</table>
</td>
<td valign="top" style="padding-top:7px;">
<asp:Literal ID="ltlCost" runat="server" /><asp:HiddenField ID="hfID" runat="server" />
</td>

<td valign="top">
<asp:Button ID="btnClearRow2" CausesValidation="false" runat="server" Text="CLEAR" OnClick="btnClearRow2_Click" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

最佳答案

当您绑定(bind)到中继器时,绑定(bind)的项目将按照它们在持有它们的集合中的顺序进行绑定(bind)。

您可以在绑定(bind)前重新排序集合。

关于asp.net - 中继器控件中的项目顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8602146/

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