Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:27:11+00:00 2026-06-05T13:27:11+00:00

I am trying to show the session value by drop down list. This is

  • 0

I am trying to show the session value by drop down list. This is what the code i made, but its not work well. correct me

    //session created

public void SAN()
        {
            cn.Open();
            string sq = "select  Sitealiasname from tbl_Sitemaster where sitename in (select sitename from tbl_emploeedetails where employeestatus='L' and employeeid='" + Session["EMPID"].ToString() + "') and    status='A' order by Sitealiasname asc";
            SqlCommand d = new SqlCommand(sq, cn);
            SqlDataReader r;
            r = d.ExecuteReader();
            while (r.Read())
            {
                Label4.Text = r["Sitealiasname"].ToString().Trim();
                Session["Sitealiasname"] = Label4.Text;
            }

            cn.Close();

        }


    //call the session to dropdownlist
     protected void Page_Load(object sender, EventArgs e)
        {
            ddlsite.Text = Session["Sitealiasname"].ToString();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:27:14+00:00Added an answer on June 5, 2026 at 1:27 pm

    Check this code if i understand exactly what you need then this will work for you.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SAN();
            bind();
    
    
        }
    }
    
    private void bind()
    {
        ArrayList ar = new ArrayList();
        ar.Add("first");
        ar.Add("Second");
        ar.Add("Third");
        ar.Add("Four");
        ar.Add("Five");
        ar.Add("Six");
        ar.Add("Seven");
        DropDownList1.DataSource = ar;
        DropDownList1.DataBind();
        DropDownList1.SelectedValue = Session["Sitealiasname"].ToString();
    }
    
    public void SAN()
        {
            cn.Open();
            string sq = "select  Sitealiasname from tbl_Sitemaster where sitename in (select sitename from tbl_emploeedetails where employeestatus='L' and employeeid='" + Session["EMPID"].ToString() + "') and    status='A' order by Sitealiasname asc";
            SqlCommand d = new SqlCommand(sq, cn);
            SqlDataReader r;
            r = d.ExecuteReader();
            while (r.Read())
            {
                Label4.Text = r["Sitealiasname"].ToString().Trim();
                Session["Sitealiasname"] = Label4.Text;//Suppose here session value "first"
            }
    
            cn.Close();
    
        }
    

    let me know if not what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get my spring DAOs to work but I only get this
I'm not sure if I've even labelled this question properly. But what I'm trying
I'm trying to show thumbnail images in Django admin, but I can only see
I am trying to store sub-query result in session variable using MySQL, but the
so i have made several attempts at this, but decided i needed some advice
Hi been trying to get this to work for ages, i have a deals
I'm trying to conditionally hide or show a <p:dataGrid> based on a session bean
Trying to show a label only when a certain item in a combo is
I am trying to show by example that the prefix increment is more efficient
I'm trying to show updated results for a CCK Computed Field. The computation is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.