c# - asp:DataGrid visibility with async? -


.net 4.5.2, iis 8.5 on windows 8.1 x64. have single asp.net web site @ /localhost/.

i've got real async-puzzle here i've been wrestling 2 days now.

i'm reworking long-running reports async, can demonstrate problem simple code.

i have asp:datagrid on page i've set visible="false". should visible if populated. problem is, if code populates async don't see grid!

here's markup:

<body>     <form runat="server">         <asp:datagrid id="grid" visible="false" runat="server"></asp:datagrid>     </form> </body> 

in code-behind, code works:

void page_load() {     grid.datasource = new dictionary<string, string>()     {         { "col1", "value1" }     };     grid.databind();     grid.visible = true; } 

now if make 2 changes:

add async="true" @page directive replace page_load this

void page_load() {     this.registerasynctask(new pageasynctask(async () =>         {             grid.datasource = new dictionary<string, string>()             {                 { "col1", "value1" }             };             grid.databind();             grid.visible = true;         })); } 

the grid not rendered. note i've used async keyword though there no await in delegate. have tried several things, same result:

  1. add await task.delay(...)
  2. remove async keyword , return task.fromresult(0)

i have overridden , instrumented page lifecycle events see when grid populated , how visiblity changes. output see:

onpreinit: visible=false rows=0 thread=63 oninit: visible=false rows=0 thread=63 oninitcomplete: visible=false rows=0 thread=63 onpreload: visible=false rows=0 thread=63 onload: visible=false rows=0 thread=63 onloadcomplete: visible=false rows=0 thread=63 onprerender: visible=false rows=0 thread=63 async 1: visible=false rows=0 thread=63 async 2: visible=true rows=1 thread=63 onprerendercomplete: visible=true rows=1 thread=63 onsavestatecomplete: visible=true rows=1 thread=63 render 1: visible=true rows=1 thread=63 render 2: visible=true rows=1 thread=63 

"async 1" , "2" on either side of grid population inside delegate. can see grid getting row , visibility gets true, yet isn't rendered. if populate grid first code sample, synchronously, well.

another note: can enclose grid in control make work:

<body>     <form runat="server">         <div id="container" visible="false" runat="server">             <asp:datagrid id="grid" runat="server"></asp:datagrid>         </div>     </form> </body> 

it seems visible="false" on asp:datagrid screws up.

what doing wrong?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -