Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to maintain dropdownlist selected item after click of a button on the same page
    text
    copied!<p>im using an update panel whose update mode is set to conditional. i want to maintain the drop down list selection after I click a button which displays a form to enter information that pertains to that particular selected dropdownlist selection. how can this be done? i enabled view state of the dropdownlist itself to be tru but it isnt working... the list value always goes back to the original default value - 0</p> <pre><code> &lt;asp:DropDownList ID="DropDownListTug" runat="server" DataSourceID="SqlDataSourceTugs" DataTextField="Tug_Name" DataValueField="Tug_ID" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="ShowNewRateBtn"&gt; &lt;asp:ListItem Value="0" Text="&amp;lt;Select&amp;gt;" Enabled="True" Selected="True"&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:Button ID="NewTug" runat="server" Text="New Tug" OnClick="NewTug_Click" CausesValidation="False" Width="74px" /&gt; &lt;asp:SqlDataSource ID="SqlDataSourceTugs" runat="server" ConnectionString="&lt;%$ g %&gt;" SelectCommand="SELECT [Tug_Name], [Tug_ID] FROM [COMIS_tbl_TugMaster]"&gt;&lt;/asp:SqlDataSource&gt; protected void ShowNewRateBtn(object sender, EventArgs e) { BtnNewRate.Visible = true; } protected void BtnNewRate_Click(object sender, EventArgs e) { try { processTugs.Visible = true; allButtons.Visible = true; BtnSave.Visible = true; BtnCancel.Visible = true; // DropDownListTug.Focus(); // DropDownListTug.EnableViewState = true; // DropDownListTug.SelectedValue = Session.... ; // } } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex); } }enter code here </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload