Click here to Skip to main content
16,016,712 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
why there is an error in selecting the value of the dropdownlist it's status doesn't change

this is the link of the project :

http://www.mediafire.com/download/u26e0s65ebgks53/test.rar[^]


C#
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeCulture();
        }
    }
    protected override void InitializeCulture()
    {
        if (Session["Drop"] == "ar-SA")
        {
        //    string str = Session["Drop"].ToString();
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ar-SA");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-SA");
        }
        else if (Session["Drop"] == "en-US")
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        }
        base.InitializeCulture();


    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["Drop"] = DropDownList1.SelectedValue;
         Response.Redirect("Default.aspx");
    }
}
Posted
Updated 20-Feb-14 6:55am
v4
Comments
Sergey Alexandrovich Kryukov 20-Feb-14 9:19am    
Please click Improve question and format the code to make it readable.
—SA
EngMamdouhAlsayed 20-Feb-14 9:28am    
thx my friend and i'm sorry because it's my first question here :) i put a link containing the whole solution :)
Sergey Alexandrovich Kryukov 20-Feb-14 12:07pm    
No need to apologize, it can be confusing at first, but actually quite simple.

Nothing prevents you from clicking and improving it. Before solving problems with ASP.NET, you need to master reasonably good level of HTML, isn't it right. For code formatting, sandwich the code sample in <pre lang="cs"> ... your code sample ... </pre>.

—SA
Krunal Rohit 20-Feb-14 9:27am    
Yeah and done it properly :)
-KR
EngMamdouhAlsayed 20-Feb-14 9:29am    
thx and i added a link containing the solution :)

1 solution

SelectedIndexChanged fires even when there is no selected item yet - when the DDL is first shown.
Check the SelectedValue and it'll initially be null - so it will set the Session that way. You need to check that you are saving / reloading a valid value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900