首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >折叠ContentTemplate中的FindControl

折叠ContentTemplate中的FindControl
EN

Stack Overflow用户
提问于 2012-08-07 22:04:21
回答 1查看 1.3K关注 0票数 0

我有一个手风琴,在我放置和下拉列表的ContentTemplate里面。我使用Accordion1_ItemDataBound将数据表绑定到dropdownlist。主要的问题是我找不到下拉列表。

代码语言:javascript
复制
<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(); 
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-07 22:11:25

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

代码语言:javascript
复制
if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)

由于您的动态链接库位于ContentTemplate中,因此语句可能需要:

代码语言:javascript
复制
if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11847734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档