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 265763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:47:53+00:00 2026-05-11T22:47:53+00:00

I have an ASP.NET webform on which I use a DropDownList control to allow

  • 0

I have an ASP.NET webform on which I use a DropDownList control to allow the user to select an item and see related results. For some reason when I set the SelectedValue property of the DropDownList the value it’s set to is not immediately available.

Here’s my code:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        DropDownList1.SelectedValue = "5";
        BindView();
    }
}

protected void BindActivities()
{
    DataClassesDataContext dc = new DataClassesDataContext();
    var query = from activity in dc.Activities
                where activity.AssignedTo == Convert.ToInt32(DropDownList1.SelectedValue);
    GridView1.DataSource = query;
    GridView1.DataBind();
}

In the previous code I get an error that DropDownList1.SelectedValue is null. The wierd thing is that if I comment out the code that uses DropDownList1.SelectedValue and let the page load, DropDownList1 is actually set to value 5. So it looks like it’s getting set correctly but is just not immediately available. The debugger confirms that DropDownList.SelectedValue is not set to 5 immediately after the line of code that sets it.

Any ideas what is going on here?

  • 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-05-11T22:47:53+00:00Added an answer on May 11, 2026 at 10:47 pm

    Are you setting the value before you have bound the dropdown list?

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer "C:\Users" means Windows Vista or 7... It may be related… May 12, 2026 at 12:57 am
  • Editorial Team
    Editorial Team added an answer I found the problem: I had a unique index on… May 12, 2026 at 12:57 am
  • Editorial Team
    Editorial Team added an answer RDBMSes aren't flat. The R part sees to that. What… May 12, 2026 at 12:57 am

Related Questions

I have an ASP.NET 3.5 GridView on a WebForm. The GridView gets data from
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------
Ok, I have a very silly question to ask (which Im rather embaressed about
I have a legacy (haha) ASP.Net Webforms Web Site Project in Visual Studio 2008
We have an ASP.Net app, that behaves strangely under IIS6. The app itself is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.