This is a migrated thread and some comments may be shown as answers.

RadGrid Rebind throws: System.Data.SqlClient.SqlException: Timeout expired

3 Answers 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 01 Nov 2011, 12:38 AM
I have a query that takes about 1.5 minutes in my datasource. It's not a large amount of data just an SSAS query that takes a while to process.

I am calling Rebind immediately after assigning datasource.

Rebind throws a timeout error at Rebind:
GridGSRComp_DataSource = new SqlDataSource(GetConnectionString()+";Connect Timeout=3000; pooling='true'; Max Pool Size=200", "GetGSRComparison " + Convert.ToInt32(ddlViewBy.SelectedValue) + ", " + Convert.ToInt32(calFrom.SelectedDate.Value.ToString("yyyyMMdd")) + ", " + Convert.ToInt32(calTo.SelectedDate.Value.ToString("yyyyMMdd")));
grdGSRComp.Rebind();

As you can see I'm setting it in the Connection string, but this does not help.

Can I set a timeout somewhere else in the radgrid or somewhere that rebind references?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2011, 04:50 AM
Hello Ken,

If you are populating the grid with NeedDataSource event it fires each time when it needs to be bound to a data source. You should never call the Rebind() method in a NeedDataSource event handler. There is no need to explicitly call Rebind() method.

-Shinu.
0
Ken
Top achievements
Rank 1
answered on 01 Nov 2011, 04:11 PM
Thanks for your reply Shinu. I had removed the call to Rebind, but still get the same timeout error message.

Here's some detail, I am using the NeedDataSource event, but I populate the data source in a button click event, with the code I've posted above. When I do this NeedDataSource isn't triggered unless I Rebind.

Here's my needDataSource event:
 
protected void grdGSRComp_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
       {
          grdGSRComp.DataSource = GridGSRComp_DataSource;           
       }

Button Click:
protected void btnViewReport_Click(object sender, EventArgs e)
         {
             if (calFrom.SelectedDate == null || calTo.SelectedDate == null)
             {
                 msgMessage.Visible = true;
                 msgMessage.Text = "Incomplete Date Range.";
             }
             else
             {
                 try
                 {
                     GridGSRComp_DataSource = new SqlDataSource(EBIReportData.GetConnectionString() + ";Connect Timeout=3000; pooling='true'; Max Pool Size=200", "GetGSRComparison " + Convert.ToInt32(ddlViewBy.SelectedValue) + ", " + Convert.ToInt32(calFrom.SelectedDate.Value.ToString("yyyyMMdd")) + ", " + Convert.ToInt32(calTo.SelectedDate.Value.ToString("yyyyMMdd")));
                     //grdGSRComp.Rebind();
                 }
                 catch(Exception ex)
                 {
                     msgMessage.Visible = true;
                     msgMessage.Text = ex.Message;
                 }
             }
              
         }

DS Property:

private SqlDataSource GridGSRComp_DataSource
        {
            get
            {
                return (SqlDataSource)Session["grdGSRComp_DataSource"];
            }
 
            set
            {
                Session["grdGSRComp_DataSource"] = value;
            }
        }

Doing this with a different set of params where the get-data doesn't take as long, the Rebind does not throw a timeout error.
I just need a way of incrementing the timeout period for the Datasource.

Thanks!


0
Ken
Top achievements
Rank 1
answered on 01 Nov 2011, 09:37 PM
Instead of a sqldatasource I created a sqlcommand and filled a datatable, this way I could control the timoeout period. 

Still have to call rebind though because otherwise the grid will not refresh when I elect to view the report with new data.
Tags
Grid
Asked by
Ken
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ken
Top achievements
Rank 1
Share this question
or