J
Jack
I have a data access component with a function that returns a dataset.
I want to access the DataTable[0].Rows.Count property of this dataset,
but I get a "Object reference not set to an instance of an object."
error when I try to access this property from a Page_Load.
The data component function that returns the DataSet:
public DataSet GetProducts(int CategoryID)
{
//clipped for clarity ...
DataSet ds = new DataSet();
myDataAdapter.Fill(ds);
myDataAdapter.Dispose();
myConnection.Close();
return ds;
}
Now on a codebehind file I have this in the Page_Load:
private void Page_Load(object sender, System.EventArgs e)
{
//clipped for clarity
test.Components.ProductsDB products = new
test.Components.ProductsDB();
DataSet myDS = new DataSet();
myDS = products.GetProducts(ProductTypeID);
ProductTypeGrid.DataSource = myDS;
// here is problem -- i am trying to set the number of total rows to a
// label
lblTotalProducts.Text = myDS.Tables[0].Rows.Count.ToString();
ProductTypeGrid.DataBind();
}
??
Thanks,
Jack
I want to access the DataTable[0].Rows.Count property of this dataset,
but I get a "Object reference not set to an instance of an object."
error when I try to access this property from a Page_Load.
The data component function that returns the DataSet:
public DataSet GetProducts(int CategoryID)
{
//clipped for clarity ...
DataSet ds = new DataSet();
myDataAdapter.Fill(ds);
myDataAdapter.Dispose();
myConnection.Close();
return ds;
}
Now on a codebehind file I have this in the Page_Load:
private void Page_Load(object sender, System.EventArgs e)
{
//clipped for clarity
test.Components.ProductsDB products = new
test.Components.ProductsDB();
DataSet myDS = new DataSet();
myDS = products.GetProducts(ProductTypeID);
ProductTypeGrid.DataSource = myDS;
// here is problem -- i am trying to set the number of total rows to a
// label
lblTotalProducts.Text = myDS.Tables[0].Rows.Count.ToString();
ProductTypeGrid.DataBind();
}
??
Thanks,
Jack