C# 部分类表适配器为空

C# 部分类表适配器为空,c#,tableadapter,command-timeout,C#,Tableadapter,Command Timeout,我想在ReportViewer使用的ObjectDataSource上设置CommandTimeout 我创建了一个分部类,但TableAdapter为null,直到我在调试中单击TableAdapter以展开属性。只有这样,TableAdapter才能获取值 代码如下: protected void ObjectDataSource2_ObjectCreated(object sender, ObjectDataSourceEventArgs e) { DataSet1TableAda

我想在ReportViewer使用的ObjectDataSource上设置CommandTimeout

我创建了一个分部类,但TableAdapter为null,直到我在调试中单击TableAdapter以展开属性。只有这样,TableAdapter才能获取值

代码如下:

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.              
}
和我的部分类代码:

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;
                    }
                }
            }
        }
    }
}
public分部类sp\u salessumaryReportTableAdapter
{
公共int SelectCommandTimeout
{
设置
{
if(this.\u commandCollection!=null)
{
对于(int i=0;i