1

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

我创建了一个部分类,但 TableAdapter 为空,直到我在调试中单击 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;
                    }
                }
            }
        }
    }
}
4

0 回答 0