我有一个手风琴,在ContentTemplate里面我放置了下拉列表。 我正在使用Accordion1_ItemDataBound将数据表绑定到下拉列表。 主要问题是我无法找到下拉列表。
<ContentTemplate>
<table border="0" width="490px" style="background-color: transparent">
<tr>
<td>
</td>
</tr>
<tr>
<td align="right">
<asp:TextBox runat="server" ID="txtNotes" TextMode="MultiLine" Height="100px" Width="200px"></asp:TextBox>
</td>
<td>
<asp:Label runat="server" ID="lbltest"></asp:Label>
<asp:DropDownList runat="server" ID="ddlStatus" Visible="true">
</asp:DropDownList>
</td>
<td>
<asp:Button runat="server" ID="btnSubmit" Text="שמור נתונים" />
</td>
</tr>
</table>
<%--<asp:Label ID="lblOrderID2" runat="server" Text='<%#Eval("MidaClient_ID")%>'></asp:Label>--%>
<%--<asp:Label ID="lblNotes" runat="server" Text='<%#Eval("Cand_Num")%>'></asp:Label>--%>
<%-- <asp:Button ID="btnSend" runat="server" Text="שלח" CommandName="send" />--%>
</ContentTemplate>
protected void Accordion1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
{
if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)
{
DataTable dt = new DataTable();
//dt = db.GetStatus();
dt.Columns.Add(new DataColumn("OfferID", typeof(int)));
dt.Columns.Add(new DataColumn("TypeOffer", typeof(string)));
dt.Rows.Add(new object[] { 0, "First Row" });
dt.Rows.Add(new object[] { 1, "Second Row" });
if (dt != null)
{
DropDownList ddl = new DropDownList();
ddl = (DropDownList)e.AccordionItem.FindControl("ddlStatus");
if (ddl != null)
{
ClientScript.RegisterStartupScript(this.GetType(), "AlertBox", "alert('dropdownlist found');", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "AlertBox", "alert('dropdownlist not found');", true);
}
//ddl.DataSource = dt;
//ddl.DataTextField = "Name";
//ddl.DataValueField = "ID";
//ddl.DataBind();
}
}
protected void LoadCandidates()
{
pds = new PagedDataSource();
pds.DataSource = db.GetCandidates(456123, 6, "1037").DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
if (SelectedPage > (pds.PageCount - 1))
SelectedPage = pds.PageCount - 1;
if (SelectedPage < 0)
{
SelectedPage = 0;
}
pds.CurrentPageIndex = SelectedPage;
Accordion1.DataSource = pds; Accordion1.DataBind();
}
答案 0 :(得分:0)
我注意到你在if语句中有Find调用:
if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)
由于您的ddl位于ContentTemplate内,因此该语句可能需要:
if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)