DataSourceID of .. must be the ID of a control of type IDataSource

G

Guest

I really do not understand what I am doing wrong.
I was trying to get familiar with WebParts and I am getting the following
error:
The DataSourceID of 'DataList1' must be the ID of a control of type
IDataSource. A control with ID 'SqlMeggitt' could not be found.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: The DataSourceID of 'DataList1'
must be the ID of a control of type IDataSource. A control with ID
'SqlMeggitt' could not be found.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): The DataSourceID of 'DataList1' must be the ID
of a control of type IDataSource. A control with ID 'SqlMeggitt' could not
be found.]
System.Web.UI.WebControls.BaseDataList.ConnectToDataSourceView() +1783839
System.Web.UI.WebControls.BaseDataList.OnLoad(EventArgs e) +16
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


The website has only one page Default.aspx and I am trying to open a small
table using a dataList control (also I tried GridView and I has the same
results.

here is the code on the page:

<asp:WebPartZone ID="MainZone" runat="server">
<ZoneTemplate>
<asp:SqlDataSource ID="SqlMeggitt"
runat="server" ConnectionString="<%$ ConnectionStrings:MSAMFconn %>"
ProviderName="<%$ ConnectionStrings:MSAMFconn.ProviderName %>"
SelectCommand="SELECT [Value], AccessType FROM MSAMF.dbo.AccessType">
</asp:SqlDataSource>
<asp:DataList ID="DataList1" runat="server"
DataKeyField="Value" DataSourceID="SqlMeggitt">
<ItemTemplate>
Value:
<asp:Label ID="ValueLabel"
runat="server" Text='<%# Eval("Value") %>'></asp:Label><br />
AccessType:
<asp:Label ID="AccessTypeLabel"
runat="server" Text='<%# Eval("AccessType") %>'>
</asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList>
</ZoneTemplate>
</asp:WebPartZone>


And here are the connectionStrings definitions (Web.config)

<connectionStrings>
<add name="MyAspNetDB"
connectionString="server=XXXX\YYYYY;database=aspnetdb;uid=sa;pwd=*******;integrated security=true" />
<add name="MSAMFconn" connectionString="Dsn=ZZZZZ;uid=sa;pwd=*****"
providerName="System.Data.Odbc" />
</connectionStrings>


Thanks,

Giovanni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top