Q:

How to persist a dropdown selected value used in Master page to all content pages in asp.net

I am designing a Job Portal. I have Master Page and in Master Page, I have used a Select Country Dropdown List.
I am displaying jobs based on user selected country in all content pages.
I just want that a user only selects one time a country and it remain selected through out all content pages. I don't want him select again and again on every content page.
I just want to persist the dropdown selected value through out the navigating in website unless user changes it again.  

A:

You can use a Session to store the value of the DropDownList
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
    <asp:ListItem Text="Netherlands" Value="nl-NL"></asp:ListItem>
    <asp:ListItem Text="England" Value="en-GB"></asp:ListItem>
    <asp:ListItem Text="Germany" Value="de-DE"></asp:ListItem>
</asp:DropDownList>

Code behind, set the correct value of the dropdown on every page load. And you can now use the value of Session["language"] to filter your data.
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //check if the session exists and select the correct value in the dropdownlist
        if (Session["language"] != null)
        {
            DropDownList1.SelectedValue = Session["language"].ToString();
        }
        else
        {
            //set the session with the default language
            Session["language"] = "en-GB";
        }
    }
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    //set the session based on the dropdownlist value
    Session["language"] = DropDownList1.SelectedValue;
}

