Note that there are some explanatory texts on larger screens.

plurals
  1. PODropDownList on masterpage - don't want it to update everytime
    primarykey
    data
    text
    <p>I'm having a little problem in my web app development. On my masterpage I have a DropDownList. Let's call it MyDDL. When I first load my app (after login) I populate it with some data from SQL database table, let's call it MyTable. No problem there. On my masterpage I also have a menu that redirects user to different pages (content) of my app. When user first selects a value from MyDDL I need it to remain no matter on wich page user clicks (because data on that page is dependand on value selected in MyDDL). Problem I have is, value in MyDDL is reset to "default" (first value in MyTable) everytime I load different page. Is there a way to solve this? Any help is appritiated. </p> <p>Here is my code behind the masterpage:</p> <pre><code>using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Configuration; public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bind(); } } public void bind() { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConn"].ToString()); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM MyTable"; cmd.CommandType = CommandType.Text; cmd.Connection = conn; conn.Open(); try { MyDDL.DataSource = cmd.ExecuteReader(); MyDDL.DataTextField = "izdelek"; MyDDL.DataBind(); } catch (Exception ex) { Response.Write(ex.StackTrace); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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