c# - Problems using UpdateProgress -


i have button on asp.net page, fetches data database , displays on gridview.

this process takes while, thought i'll add updateprogress ajax control. when click button, updateprogress image shows , data being fetched database (i checked logs have in db). there 2 issues:

(1) updateprogress image shows 2 minutes. buttonclick event takes 5 minutes complete. updateprogress stops showing before task complete, defeats purpose.

(2) gridview doesn't show up. shows correctly if don't use scriptmanager/ajax.

any ideas?

some relevant code snippets:

<div style="position: absolute; top: 300px; left: 19px; width: 568px; height: 48px;">     <table>         <tr>         <td>     <asp:button id="btngeneratereport" runat="server" height="37px" text="generate report"          width="132px" onclick="btngeneratereport_click" />         </td>         <td class="style5">     <asp:scriptmanager id="scriptmanager1" runat="server" />     <asp:updatepanel runat="server" id="panel">     <contenttemplate>             <asp:updateprogress id="pageupdateprogress" runat="server">                 <progresstemplate>                     <img runat="server" src="updateprogress.gif"                          style="position: static; width: 32px;"> </img></progresstemplate>             </asp:updateprogress>             <div style="position: absolute; top: 423px; left: 9px; width: 795px; height: 984px;">         <asp:gridview id="report" runat="server"              allowsorting="true" autogeneratecolumns="false"              height="622px" borderstyle="solid"              width="779px" pagesize="100" horizontalalign="center">             <columns>                 <asp:boundfield headertext="accountid" datafield="accountid">                 <controlstyle borderstyle="solid" width="20px" />                 </asp:boundfield>                 <asp:boundfield headertext="user name" readonly="true" datafield="username">                 <controlstyle width="50px" />                 </asp:boundfield>                 <asp:boundfield headertext="c2" readonly="true"                      datafield="c2">                 <controlstyle borderstyle="solid" width="20px" />                 </asp:boundfield>                 <asp:boundfield headertext="c1" readonly="true"                      datafield="c1">                 <controlstyle borderstyle="solid" width="20px" />                 </asp:boundfield>             </columns>         </asp:gridview>     </div>     </contenttemplate>     <triggers>             <asp:asyncpostbacktrigger controlid="btngeneratereport" eventname="click" />     </triggers>     </asp:updatepanel>         </td>         <td>         <asp:button id="btnexporttoexcel" runat="server" text="export excel"                  height="37px" width="132px" onclick="btnexporttoexcel_click" />         </td>         </tr>     </table>     </div> 

codefile part:

protected void btngeneratereport_click(object sender, eventargs e)         {              fetchaccounts();             long startid = fetchauditdata();             aggregateauditdata(startid);             dsanalysisreport = generatedataset();             if (dsanalysisreport == null || dsanalysisreport.tables.count == 0)                 lblerrortext.text = "no data found input information";             else                 binddata(dsanalysisreport);         }          public void fetchaccounts()         {             using (var sqlconnection = new sqlconnection(connectionstring))             {                 sqlconnection.open();                 cmdstring = @"[spo_fetchaccounts]";                 cmd = new sqlcommand(cmdstring, sqlconnection) { commandtype = commandtype.storedprocedure };                 cmd.commandtimeout = 100000;                 cmd.parameters.add("@maxactivationdate", sqldbtype.datetime);                 cmd.parameters["@maxactivationdate"].value =                     datetime.parse(txtstartdate.text) - new timespan(1, 0, 0, 0);                 cmd.executenonquery();                 sqlconnection.close();             }         }          public long fetchauditdata()         {             using (var sqlconnection = new sqlconnection(connectionstring))             {                 sqlconnection.open();                  cmdstring = @"[spo_getcomparisondata]";                 cmd = new sqlcommand(cmdstring, sqlconnection) { commandtype = commandtype.storedprocedure };                 cmd.commandtimeout = 100000;                 cmd.parameters.add("@startdate", sqldbtype.datetime);                 cmd.parameters["@startdate"].value = txtstartdate.text;                 cmd.parameters.add("@enddate", sqldbtype.datetime);                 cmd.parameters["@enddate"].value = txtenddate.text;                 sqlparameter returnvalue = new sqlparameter("@return_value", sqldbtype.bigint);                 returnvalue.direction = parameterdirection.returnvalue;                 cmd.parameters.add(returnvalue);                 cmd.executenonquery();                 long startid = long.parse(cmd.parameters["@return_value"].value.tostring());                 sqlconnection.close();                 return startid;             }         }          private void aggregateauditdata(long startid)         {             using (var sqlconnection = new sqlconnection(connectionstring))             {                 sqlconnection.open();                 cmdstring = @"[spo_comparisontable]";                 cmd = new sqlcommand(cmdstring, sqlconnection) { commandtype = commandtype.storedprocedure };                 cmd.commandtimeout = 100000;                 cmd.parameters.add("@startid", sqldbtype.int);                 cmd.parameters["@startid"].value = startid;                 cmd.executenonquery();                 sqlconnection.close();             }         }           public dataset generatedataset()         {              using (var sqlconnection = new sqlconnection(connectionstring))             {                 sqlconnection.open();                 cmdstring = @"select * xaccounts";                 cmd = new sqlcommand(cmdstring, sqlconnection);                 dataset ds = new dataset();                 sqldataadapter da = new sqldataadapter(cmd);                 da.fill(ds);                 sqlconnection.close();                 if (ds.tables.count > 0 && ds.tables[0].rows.count > 0)                     return ds;                 return null;             }             }          private void binddata(dataset ds)         {             bindreportgrid(report, ds.tables[0]);         }          private void bindreportgrid(gridview gridtobind, datatable datatabletobind)         {             gridtobind.datasource = datatabletobind;             gridtobind.databind();         } 

as per issue (1) ajax timing out. default timeout 90 seconds. increase use scriptmanager's asyncpostbacktimeout property:

<asp:scriptmanager id="scriptmanager1" runat="server" asyncpostbacktimeout="400"> </asp:scriptmanager> 

if ajax call timing out, controls on page might not work correctly increasing timeout might solve problem (2) well.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -