Partial Class Table Adapter is null

108 Views Asked by At

I would like to set the CommandTimeout on an ObjectDataSource used by ReportViewer.

I created a partial class, but the TableAdapter is null until I click on the TableAdapter in debug to expand the properties. Only then does the TableAdapter get values.

Here is the code:

protected void ObjectDataSource2_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
{
    DataSet1TableAdapters.sp_SalesSummaryReportTableAdapter ta; 
    ta = (DataSet1TableAdapters.sp_SalesSummaryReportTableAdapter)e.ObjectInstance;
    ta.SelectCommandTimeout = 0;  //Here ta is null until I click on ta in debug and expand the values.              
}

and my partial class code:

public partial class sp_SalesSummaryReportTableAdapter
{
    public int SelectCommandTimeout
    {
        set
        {
            if (this._commandCollection != null)
            {
                for (int i = 0; i < this._commandCollection.Length; i++)
                {
                    if ((this._commandCollection[i] != null))
                    {
                        ((System.Data.SqlClient.SqlCommand)
                        (this._commandCollection[i])).CommandTimeout = value;
                    }
                }
            }
        }
    }
}
0

There are 0 best solutions below