Welcome Guest Search | Active Topics | Sign In | Register

Cannot Load Grid from SQLDataReader Options
Dave
Posted: Friday, April 4, 2008 1:53:00 PM
Rank: Advanced Member
Groups: Member

Joined: 4/4/2008
Posts: 46
Ok guys.... What am I doing wrong here? After purchasing the EO ASP Suite this morning, I'm actually a bit frustrated and dissapointed. It simply should not be this difficult to populate a grid.

Here's the code:

public void ReadEmployeeTable()
{

using (SqlConnection myConnection = new SqlConnection(sConnectionString))
{
//SqlDataReader myReader;
myConnection.Open();

string mySelectQuery = "SELECT lname, fname from employee";
SqlCommand myCmd1 = new SqlCommand(mySelectQuery, myConnection);

//myReader = myCmd1.ExecuteReader();

employeeGrid.DataSource = myCmd1.ExecuteReader();
employeeGrid.DataBind();

myConnection.Close();
}
}

Here's the runtime error that I'm getting:

The Grid control does not support DataSourceID. Please fill a DataTable from the data source control, then populate the Grid from the DataTable.
eo_support
Posted: Friday, April 4, 2008 1:57:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

You need to clear the Grid's DataSourceID property. You are binding through its DataSource and DataBind(), and your code seems to be correct --- make sure you have all the columns and each column's DataField set properly.

Thanks
Dave
Posted: Friday, April 4, 2008 2:06:14 PM
Rank: Advanced Member
Groups: Member

Joined: 4/4/2008
Posts: 46
Yep.... That worked!!!! The problem was that the DataSource Property had "(None)" set.
Dave
Posted: Friday, April 4, 2008 2:08:22 PM
Rank: Advanced Member
Groups: Member

Joined: 4/4/2008
Posts: 46
Thanks for the quick reply!!!!

Dave


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.