protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 0;
}
<asp:GridView ID="GridViewExcel" runat="server" DataSourceID="QuerySource" emptydatatext="No data available." >
</asp:GridView>
<asp:sqldatasource id="QuerySource" SelectCommand="SqlDataSource1_Selecting" DataSourceMode="DataSet"
connectionstring="<%$ ConnectionStrings:Conn %>"
runat="server"/>
The QuerySource I have is dynamic, so any time an user can select the criteria, and hit submit it will run it. One of the criterias is a StartDate and EndDate. The longer the date, the more data will be return. For example, if I only 2 day range, it runs fine, but if I select 200 range it time out. The interesting thing is if I run the 2 day range first and then change the date range to 200, it won't time out. So I think the e.Command.CommandTimeout = 0 is not initialized when I run the query the first time and that's why it is timing out if I start the application and run 200 date. So is there a way for me to set e.Command.CommandTimeout = 0 before it is run? Is that make sense?