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>
<aspataList 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>
</aspataList>
</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
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>
<aspataList 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>
</aspataList>
</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