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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:26:14+00:00 2026-06-17T09:26:14+00:00

I have a dropDownlist in my project and i am adding items to it

  • 0

I have a dropDownlist in my project and i am adding items to it in javascript. Now i want to get selected index in C# (on a button click event). But i am unable to do this because it seems to be a problem that viewstate is not maintained.
Further more i have

EnableEventValidation="false" 

in my Page
Please tell me how can i achieve this functionality? Right Now i am adding selected values in a hidden field and then accessing that hidden field in C#. Its working but i want “cleanliness”.

Regards

  • 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-17T09:26:15+00:00Added an answer on June 17, 2026 at 9:26 am

    When ASP.NET performs a form POST the drop down options need to be passed through to the server and be recreated there for further processing.This is achieved through ViewState.

    I’m not aware of any other way of doing this, what you can do however is retrieve the selected value of the drop down using Request.Form[ddlProducts.UniqueID] if you can figure out the item index based on the selected value, great! Else I think hidden fields are your only option

    Here’s a complete example:

    <head runat="server">
        <title></title>
        <script type="text/javascript">
            window.onload = function () {
                var select = document.getElementById("ddlProducts");
                select.options[select.options.length] = new Option('Product 1', 'Value 1');
                select.options[select.options.length] = new Option('Product 2', 'Value 2');
                select.options[select.options.length] = new Option('Product 3', 'Value 3');
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="ddlProducts" runat="server">
            </asp:DropDownList>
            <asp:Button ID="btnOK" runat="server" Text="OK" OnClick="Process" />&nbsp;<span id="output"
                runat="server" />
        </div>
        </form>
    </body>
    </html>
    
    protected void Process(object sender, EventArgs e)
    {
        int selectedIndex = ddlProducts.SelectedIndex;
        output.InnerHtml = Request.Form[ddlProducts.UniqueID];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdownlist and a button. I used the breakpoint in my project
I have used spinner in my project but it looks like But i want
I have DropDownList with CascadingDropDown extender. If I want to retrieve data from the
I have a DropDownList with an SelectedIndexChanged event listener <asp:DropDownList ID=LoanOptionCombo runat=server AutoProstBack=True> Listener
I have a dropdownlist and a textbox with a button on a form. When
i have asp.net project which has dropdownlist. i need to insert data into my
In my ASP.NET project. I have two dropdownlist and a checkbox. When the checkbox
I have a 3 dropdownlist control with a selectedindexchanged event that fires correctly. However,
I have a simple ASP.NET dropdownlist control in a visual studio project (.NET framework
In my project I have placed a dropdownlist in an updatepanel.what I wanted to

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.