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.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Yep.... That worked!!!! The problem was that the DataSource Property had "(None)" set.
|
Rank: Advanced Member Groups: Member
Joined: 4/4/2008 Posts: 46
|
Thanks for the quick reply!!!!
Dave
|