0

我有一个手风琴,在我放置的 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(); 
}
4

1 回答 1

0

我注意到你在这个 if 语句中有 Find 调用:

if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)

由于您的 ddl 在 ContentTemplate 内,因此该语句可能需要:

if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
于 2012-08-07T14:11:24.587 回答