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.)
Your Ad Here