Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two accordion panes on a page and one of them includes a
DropdownList. I want to fill that DropdownList on page load but null
reference error occurs if the AccordionPane on which the DropdownList
exists is collapsed .Well but how can I fill my
little poor DropdownList with some data?

Thanks in advance.
Posted

Hi,

If you familier with Jquery you can use my code for filling dropdown list

from browser side when page loads in web browser.

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript" >
        function f1() {
            $("#DropDownList1").html("<option value='fdgfdg'>gfdg</option><option value='dfgg'>gfdg");

        }
    </script>
</head>
<body onload ="f1()">
    <form id="form1" runat="server">
    <div>
       
        <asp:dropdownlist id="DropDownList1" runat="server" xmlns:asp="#unknown">
      
        </asp:dropdownlist>
     
    </div>
    </form>
</body>
</html>


Just try it ,If you interested in it.

post your requirement clearly thn i'll help you.


All the Best
 
Share this answer
 
Could you please try accessing the DropDownList by using FindControl method of the Accordion/Accordion Pane.
 
Share this answer
 
try this one


XML
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:Accordion ID="Accordion1" runat="server">
        <Panes>
        <asp:AccordionPane ID="ap1" runat="server">
        <Header>
        DropDown1
        </Header>
        <Content>
        <asp:DropDownList runat="server">
        <asp:ListItem>
        ONE
        </asp:ListItem>
        <asp:ListItem>
        TWO
        </asp:ListItem>
        <asp:ListItem>
        THREE
        </asp:ListItem>
        </asp:DropDownList>
        </Content>
        </asp:AccordionPane>
        <asp:AccordionPane ID="ap2" runat="server">
        <Header>
        DropDown2
        </Header>
        <Content>
        <asp:DropDownList runat="server">
        <asp:ListItem>
        FOUR
        </asp:ListItem>
        <asp:ListItem>
        FIVE
        </asp:ListItem>
        <asp:ListItem>
        SIX
        </asp:ListItem>
        </asp:DropDownList>
        </Content>

        </asp:AccordionPane>
        </Panes>
        </asp:Accordion>
     </div>
    </form>
</body>
 
Share this answer
 
v2
Comments
Lalit Pachauri 26-May-14 6:12am    
how to fill dropdown from database (SQL) with edit and footer template inside accordion having more than one pane

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900