Thursday, October 11, 2007

Both DataSource and DataSourceID are defined

I was displaying data to a GridView via DataSet when the webpage returned this error:

Both DataSource and DataSourceID are defined on 'gvConfig'. Remove one definition.

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.InvalidOperationException: Both DataSource and DataSourceID are defined on 'gvConfig'. Remove one definition.

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:
[InvalidOperationException: Both DataSource and DataSourceID are defined on 'gvConfig'. Remove one definition.]
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +367
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +35
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3037


However upon debugging the problem, I got this exception message:
The IListSource does not contain any data sources.

True to the exception, the DataSet I was getting from the WebService had no tables defined, thus no data, thus the error.

Still I don't understand why I encountered such error on the webpage despite it not being relevant to the true exception. (Or perhaps I'm just too daft.)

1 comment:

Anonymous said...

Apparently it's a bug in .NET.

I had a different bug in my data access code and also got this very confusing "Both DataSource and DataSourceID are defined" error. Once i had solved the real bug the confusing error message went away.

Your Ad Here