Has anyone solved this error? I am creating a composite control that creates a
dataset which gets data from the authors table in pubs and then binds to a
DataGrid. The error occurs when the DataGrid is added to the Controls collection.
Here is the code sample:
public class MyCtrl : Control
{
protected override void CreateChildControls()
{
SQLConnection oConnection = new SQLConnection(sConnStr);
SQLCommand oCommand = new SQLCommand("select * from authors", oConnection);
SQLDataSetCommand dsCmd = new SQLDataSetCommand("select * from authors",
sConnStr);
DataSet ds = new DataSet();
dsCmd.FillDataSet(ds, "authors");
System.Web.UI.WebControls.DataGrid authors = new
System.Web.UI.WebControls.DataGrid();
authors.DataSource = ds.Tables["authors"].DefaultView;
authors.ID = "authid";
authors.DataBind();
Controls.Add(authors); // error happens here
}
Quote:}