我在我的弹出函数中有一个下拉列表,它没有加载我想要的数据,我已经设置了断点并确认我得到了我想要的数据,但由于某种原因,下拉列表仍然是空的。
C#:
C#:
protected void Page_PreRender(object sender, EventArgs e)
{
var nodes = _administrationSystem.GetNodes(); //The dataset with data
var translators = _phonesSystem.GetPhoneNumberTranslators(); //The dataset with data
if (rptList.Items.Count > 0)
{
for (var count = 0; count < rptList.Items.Count; count++)
{
var ddlNodeEdit = (DropDownList)rptList.Items[count].FindControl("ddlNodeEdit");
var ddlTranslatorEdit = (DropDownList)rptList.Items[count].FindControl("ddlTranslatorEdit");
ddlNodeEdit.DataSource = nodes;
ddlNodeEdit.DataTextField = "NodeName";
ddlNodeEdit.DataValueField = "ID";
ddlNodeEdit.DataBind();
ddlNodeEdit.Items.Insert(0, new ListItem("TRNSLTChoose node", "0"));
ddlTranslatorEdit.DataSource = translators;
ddlTranslatorEdit.DataTextField = "Description";
ddlTranslatorEdit.DataValueField = "ID";
ddlTranslatorEdit.DataBind();
ddlTranslatorEdit.Items.Insert(0, new ListItem("TRNSLTChoose numbertranslator", "0"));
}
}
}
ASPX:
<asp:Repeater runat="server" OnItemCommand="rptList_OnItemCommand" ID="rptList">
<HeaderTemplate>
<table class="tblRegister">
<tr class="tblRowHeader" style="background-color: rgb(200,200,200)">
<th>
<asp:Label runat="server" Text="TRNSLTFirstname" />
</th>
<th>
<asp:Label runat="server" Text="TRNSLTSurname" />
</th>
<th>
<asp:Label runat="server" Text="TRNSLTNode index" />
</th>
<th>
<asp:Label runat="server" Text="TRNSLTNumber translation" />
</th>
<th>
<asp:Label runat="server" Text="TRNSLTEmail" />
</th>
<th colspan="3">
<asp:Label runat="server" Text="TRNSLTLast login" />
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<%# OperatorId.HasValue && OperatorId == Convert.ToInt32(Eval("ID"))? "<tr style='background-color: #94C5E1;'>" : "<tr>" %>
<td>
<%# Eval("FirstName") %>
</td>
<td>
<%# Eval("SurName") %>
</td>
<td>
<%# Eval("NodeIndex") %>
</td>
<td>
<%# Eval("TranslatorName") %>
</td>
<td>
<%# Eval("EMail") %>
</td>
<td>
<%# Eval("LastLogin") %>
</td>
<td>
<asp:LinkButton ToolTip="TRNSLTDelete" ID="btnDelete" CssClass="deleteOperator" runat="server" CommandName="deleteBtn" CommandArgument='<%# Eval("ID") %>' OnClientClick="return OpenPopup(this)">
<asp:Image ImageUrl="Images/Icons/Deleted-16x16.png" ID="DeleteVisitor" runat="server" />
</asp:LinkButton>
<div id="myModal" class="modal">
<div class="modal-content">
<h3 class="modalHdr">
<asp:Label runat="server" Text="TRNSLTRemove users" />
</h3>
<asp:LinkButton ToolTip="TRNSLTNo" CommandName="noBtn" CommandArgument='<%# Eval("ID") %>' ID="ButtonNo" runat="server" Text="TRNSLTNo" CssClass="popupConfirm" />
<asp:LinkButton ToolTip="TRNSLTYes" CommandName="yesBtn" CommandArgument='<%# Eval("ID") %>' ID="ButtonYes" runat="server" Text="TRNSLTYes" CssClass="popupConfirm" />
</div>
</div>
</td>
<td>
<asp:LinkButton CommandName="selectBtn" ToolTip="TRNSLTEdit" ID="btnEdit" CssClass="editOperator" runat="server" CommandArgument='<%# Eval("ID")%>' OnClientClick="return PopupEdit(this)">
<asp:Image ImageUrl="Images/Icons/Edit-16x16.png" ID="EditVisitor" runat="server" />
</asp:LinkButton>
<div id="modalEdit" class="modal">
<div class="modal-content">
<p style="margin-left: 50px;">
<img src="Images/Icons/Sip.png" alt="" />
<%# Eval("FirstName") %> <%# Eval("SurName") %>
</p>
<br />
<asp:DropDownList CssClass="ddlNodeClass" runat="server" ID="ddlNodeEdit" />
<asp:DropDownList CssClass="ddlTranslatorClass" runat="server" ID="ddlTranslatorEdit" />
<asp:LinkButton ToolTip="TRNSLTCancel" CommandArgument='<%# Eval("ID") %>' ID="btnNo" runat="server" CssClass="btnCancelClass" OnClientClick="return Cancel(this)">
<asp:Image ImageUrl="Images/Icons/Cancel-22x22.png" ID="SaveContact" runat="server" ClientIDMode="Static" />
</asp:LinkButton>
<asp:LinkButton ToolTip="TRNSLTSave" CommandName="submitBtn" CommandArgument='<%# Eval("ID") %>' ID="btnYes" runat="server" CssClass="btnSaveClass">
<asp:Image ImageUrl="Images/Icons/Check-22x22.png" ID="SaveOperator" runat="server" ClientIDMode="Static" />
</asp:LinkButton>
</div>
</div>
</td>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
AutoPostBack="True"
,但仍然没有任何作用。 - Malphai