title: DropDownList set selected item to true
body: <p>I have added DropDownList in ASP.net. </p>
  
  <pre><code>&lt;asp:DropDownList  ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" &gt; 
  &lt;asp:ListItem Text="Name" Value="jsh" Selected="true" /&gt; 
  &lt;asp:ListItem Text="hhh" Value="sds"/&gt; 
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>Instead on saying <code>Selected="true"</code> in ASP.net i want to set the selected item using C# inside the </p>
  
  <pre><code>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
  {
      DropDownList1 // THE SELECTED ITEM NEEDS TO BE SET TO TRUE
      Response.Redirect(Request.RawUrl);
  }
  </code></pre>
  
  <p>UPDATE</p>
  
  <pre><code>&lt;asp:DropDownList  ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" OnTextChanged="DropDownList1_onChanged"&gt; 
  
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
  
      if(!Page.IsPostBack)
  {
      DropDownList1.Items.Add(new ListItem("En", "en-US"));
      DropDownList1.Items.Add(new ListItem("Fr", "fr-FR"));
  }
  
  }
  </code></pre>
  
  <p>// I also copied <code>InitializeCulture()</code></p>
  
  <pre><code>protected override void InitializeCulture() 
  {
  
  string Kultur = "en-US"; 
  if (Session["lang"] != null)
  {
  
  
      Kultur = Session["lang"].ToString();
  }
  
  
  this.UICulture = Kultur;
  this.Culture = Kultur;
  base.InitializeCulture();
  
  
  }
  </code></pre>
  
  <p>//</p>
  
  <pre><code>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
  {
  DropDownList1.Items.FindByValue(DropDownList1.SelectedValue).Selected = true;
    Response.Redirect(Request.RawUrl);
  }
  </code></pre>