1

I'm trying to populate one dropdownlist from another dropdownlist (filter the data) I understand that I suppose to make a scriptmanager but it gives me an error:

The control with ID '' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

This is my code:

 <td>School</td>
     <td>
         <asp:ScriptManager ID="ScriptManager1" runat="server" />
         <asp:DropDownList ID="SchoolRegister" runat="server" AutoPostBack="True" 
             DataSourceID="SqlDataSource1" DataTextField="SchoolName" DataValueField="ID">
         </asp:DropDownList>
         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
             ConnectionString="<%$ ConnectionStrings:DanielConnectionString %>" 
             SelectCommand="SELECT * FROM [Schools]"></asp:SqlDataSource>
     </td>
 </tr>
 <tr>
     <td>Class</td>
     <td>
         <asp:ScriptManager ID="ScriptManager2" runat="server" />
         <asp:DropDownList ID="ClassRegister" runat="server" 
             DataSourceID="SqlDataSource2" DataTextField="ClassName" DataValueField="ID">
         </asp:DropDownList>
         <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
             ConnectionString="<%$ ConnectionStrings:DanielConnectionString %>" 
             SelectCommand="SELECT * FROM [Class] WHERE ([SchoolID] = @SchoolID)">
             <SelectParameters>
                 <asp:ControlParameter ControlID="SchoolRegister" Name="SchoolID" 
                     PropertyName="SelectedValue" Type="Int32" />
             </SelectParameters>
         </asp:SqlDataSource>
     </td>
 </tr>

Thanks.

1
  • For some reason it doesnt paste me the whole code in here..I'll try to fix that . sorry Commented Dec 28, 2011 at 21:20

3 Answers 3

1

You have multiple ScriptManager controls on your page. You only need one, and it should be placed near the top of your page.

Sign up to request clarification or add additional context in comments.

2 Comments

And you removed the second ScriptManager? I feel like some code is missing from your example.
Yes, I did. Should I do something else beside stick the ScriptManager code in the header?
1

Are you using master pages? You only need one script manager on the page. Add it directly after the opening body tag so it appears before all the controls that may require it.

If you add one to the master page it will work for all content pages.

2 Comments

Dont have a master page, but I tried to place it just after the body tag and remove it from the last place I've put it , and it still make me the same error
Are you using the ajax toolkit? You try the scriptmanager from there <ajaxToolkit:ToolkitScriptManager ID="scriptManager" runat="server" />
0

I solved this problem by making a <ContentTemplate> tag.

Thanks for all the helpers :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.