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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:17:51+00:00 2026-06-06T01:17:51+00:00

I have an asp dropbox which I populate from database: this is the aspx

  • 0

I have an asp dropbox which I populate from database:

this is the aspx

<asp:DropDownList runat="server" ID="ddl_last" AppendDataBoundItems="true">

and this is the cs:

  ddl_last.DataSource = eggsContext.Customers;
        ddl_last.DataValueField = "last_name";
        ddl_last.DataTextField = "last_name";
        ddl_last.DataBind();

When I try to get ddl_last.SelectedValue from the c# code I get nothing. infact ddl_last.Items count is 0! When I don’t populate it from code, but write in the aspx

<asp:ListItem Text="example" />

everything works.

I can get the value from javascript by writing
document.getElementById(‘ddl_last’).value;

But I was wondering what did microsoft screw up this time that this is not working from the code behind?

  • 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-06T01:17:53+00:00Added an answer on June 6, 2026 at 1:17 am

    After seeing your issue in comment, I think this may help you resolve it:

    To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.

    http://msdn.microsoft.com/en-us/library/system.web.ui.control.viewstatemode.aspx

    Note also, with ViewState being disabled, you can still retrieve the posted value by

    if (Request["ddl_last"] != null)
        val = Request["ddl_last"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp repeater which looks like this <asp:Repeater runat=server ID=Repeater1> <HeaderTemplate> <table border=1>
i have asp button like this: <asp:Button ID=ImportToDB runat=server OnClick=ImportToDB_Click /> And i need
I have asp:datalist binding from table this table contain two columns one of them
i have asp text box and button control. <asp:TextBox ID=txtFName runat=server CssClass=sfInputbox></asp:TextBox> <asp:Button runat=Server
I have asp.net application where i have a div which showing the value from
I have asp (classic) script and within javascript code. From database I get date
I have asp.net mvc 4 web application project on my server in IIS Directory.
I have asp.net TextBox with ontextchanged event this is search text box in my
I have ASP.NET project which do some file access and manipulation, the methods which
We have ASP.NET MVC 3 application which is integrated with Google Checkout API .

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.