Let's first look at the difference between
DataSource
and
DataSourceID
.
Quote:
DataSource refers to actual data source object which can be .NET provided data source controls (such as ObjectDataSource, SqlDataSource) or actual data objects such as DataTable, Collection of objects etc.
DataSourceID is the string identifier for .NET provided data source control and this property exists so that data-bound control and corresponding data source can be associated at the design time in markup. Internally, the control would look up for actual data source control using the id provided.
1. Make sure, you have not mentioned
DataSourceID
in the code behind. Something like-
Gridview1.DataSourceID="ds";
2. Try-
GridView1.DataSource = ds.Table[0];
3. Try-
Gridview1.DataSourceID = null;
GridView1.DataSource = ds.Table[0];
GridView1.DataBind();
Hopefully, one of the above solution/workaround works for you :)