Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On the design side, I have this:

<asp:DropdownList ID="ddlSystemSubTypeSearch" runat="server" DataSourceID="sdsSystemSubTypes" DataTextField="stSystemSubType" DataValueField="sstSTID" Width="250px"></asp:DropdownList>


And on the code behind side, I have this:

VB
If Trim(Request.QueryString("SystemSubType")) <> String.Empty Then
                  Me.ddlSystemSubTypeSearch.DataBind()
                  Me.ddlSystemSubTypeSearch.SelectedValue = Request.QueryString("SystemSubType").Trim
              End If



VB
Private Sub ddlSystemSubTypeSearch_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSystemSubTypeSearch.DataBound
       Me.ddlSystemSubTypeSearch.Items.Insert(0, New ListItem("", -1))
   End Sub



When I run the program, I get this error:

Quote:
The DataSourceID of 'ddlSystemSubTypeSearch' must be the ID of a control of type IDataSource. A control with ID 'sdsSystemSubTypes' could not be found.


Seems I can't figure out what is wrong with the code.
Any help will be greatly appreciated.
Posted

The error is telling you that it is searching for a Control with ID sdsSystemSubTypes. If you have not declared any of such DataSource control like SqlDataSource or something, then it would throw you this.

Refer - BaseDataBoundControl.DataSourceID Property[^] for one example.
 
Share this answer
 
I declared the control like this:

XML
<asp:SqlDataSource ID="sdsSystemSubTypes" runat="server"
          ConnectionString="<%$ ConnectionStrings:ClassicAutomation %>"
          ProviderName="<%$ ConnectionStrings:ClassicAutomation.ProviderName %>"
          SelectCommand="spWC_GetSystemSubTypes" SelectCommandType="StoredProcedure">
  </asp:SqlDataSource>



And it solved the problem. Thanks Tadit.
 
Share this answer
 
Comments

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