.net - ASP.NET Viewstate bug - updating some controls (incorrectly) and not others -


i have combobox which, when select different options, triggers updatepanel containing gridview refresh new data depend on combobox selected item, via ajax postback.

all works fine, except if i:

  1. select different entry in combobox 1 selected on page load (which first one). triggers gridview refresh.
  2. hit refresh.

the refreshed screen loads first entry in combobox selected, , appropriate content first item in gridview. combobox changed entry selected in step 1 above - presumably restored viewstate. gridview not updated - shows data default combobox selection - 2 out of sync. if click in browser url box , hit enter, plain get of url, resets correctly.

i tried adding add enableviewstate="false" viewstatemode="disabled" on combobox, still, when refresh, gridview resets, combo returns non-default value. in fact seems make things worse - if load page, select different combobox item, , hit refresh - selecting default combo item calls postback, receives 200 response, gridview no longer updates - until clear session either loggin out or restarting server. @ least viewstate enabled can recover selecting different entries in combobox.

i have similar problem, assume down not understanding viewstate. in gridview textboxes. these textboxes autopostback="true", calls update sql in asp:sqldatasource. avoid user continuing enter text during postback, have javascript function on onblur event of textbox disable during postback. when row re-rendered, disabled state recovered. have tried setting enabled=true , readonly=false, both in asp markup, , in load codebehind event, can't prevent textboxes being left in disabled state. assume viewstate-related issue. i've lot of experience in web development, none asp.net.

the combobox (dsareacombo simple select):

<asp:dropdownlist id="cmbprovince" runat="server" class="form-control dropdown" autopostback="true"      data-placeholder="choose province"      datasourceid="dsareacombo" datatextfield="provincedescription" datavaluefield="regionid"> </asp:dropdownlist> 

the gridview:

<asp:gridview id="grdpbbbudget"      datasourceid="dspbbbudget"      autogeneratecolumns="false"     datakeynames="parentproductid, segmentid"     onrowupdating="grdpbbbudget_rowupdating"     onrowupdated="grdpbbbudget_rowupdated"     onrowdatabound="grdpbbbudget_rowdatabound"     runat="server">     <columns>         <asp:boundfield datafield="grandparentproductdescription"             readonly="true" /> ...                 <asp:templatefield headertext="accounts">                     <itemtemplate>                         <asp:textbox id="accounts"                             text='<%#eval("accounts", "{0:f0}")%>'                             runat="server"                             autopostback="true"                              ontextchanged="accounts_textchanged"                             onblur="return disable_for_postback(this, true);"                              dataformatstring="{0:f0}"                             class="inline-input"/>                     </itemtemplate>                 </asp:templatefield>             </columns>         </asp:gridview>     </contenttemplate>     <triggers>         <asp:asyncpostbacktrigger controlid="cmbprovince" eventname="selectedindexchanged" />     </triggers> </asp:updatepanel> 

rowdatabound formatting. textchanged events call grd.updaterow. rowupdating event pulls values textboxes onto e.newvalues. rowupdated event triggers databind on gridview. dspbbbudget select , update stored procedure call.

my question how can better understand viewstate fundamentals can fix these , avoid pitfalls in future?


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -