Why does the Combo.SelectedValue get lost after some time
Posted
by tzup
on Stack Overflow
See other posts from Stack Overflow
or by tzup
Published on 2009-10-16T10:04:31Z
Indexed on
2010/03/28
4:03 UTC
Read the original article
Hit count: 392
So I have this asp:DropDownList on a page. It renders like this (in IE7):
<select name="ctl00$cphFilter$cbLista" onchange="javascript:setTimeout('__doPostBack(\'ctl00$cphFilter$cbLista\',\'\')', 0)" id="ctl00_cphFilter_cbLista" class="agsSelect">
<option selected="selected" value="4350">A</option>
<option value="4352">B</option>
<option value="4349">C</option>
<option value="4348">D</option>
And then I have a grid and a button on the same page. When the user clicks the button the selected item of the dropdown is read (well a datasource object reads it) and the grid does a databind after a trip to a DB where it gets some data based on that selected value.
This works fine most of the time. However sometimes, the selection in the dropdownlist seems to get lost even though the rendered page says the A is the selected item.
The datasource object is defined like this:
<asp:ObjectDataSource ID="dsVM" runat="server" EnablePaging="False" SelectMethod="Select" SortParameterName="sort" TypeName="X.Business.Entities.LPVM.BE">
<SelectParameters>
<asp:ControlParameter Name="listaId" Type="Int32" ControlID="cphFilter$cbLista" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
Any ideas why the grid would reload its data with a select parameter that is 0 instead of the selected value of the dropdownlist?
EDIT Suppose the dropdownlist is bound, the user selected B and the grid is bound as well and shows the right data. Now, I wait 2 minutes and I click the Refresh button. Surprisingly, at this particular moment the dropdownlist.SelectedValue (which I already know it was 4352 before I clicked because that's how it looks in the rendered page) is actually an empty string. Where did the value go?
© Stack Overflow or respective owner