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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:50:27+00:00 2026-06-16T13:50:27+00:00

I have an asp Button and four drop down lists that are populated dynamically

  • 0

I have an asp Button and four drop down lists that are populated dynamically from a database. When clicking the button, supposed to pass the selected values from the drop down list to a SQL stored procedure. Instead the first value in each drop down list is being passed instead of the selected value. Here is the code on the aspx page:

<asp:DropDownList runat="server" ID="ddlCountry" AppendDataBoundItems="True">
</asp:DropDownList>
&nbsp;
<asp:DropDownList runat="server" ID="ddlTypeStructure" AppendDataBoundItems="True">
 </asp:DropDownList>
&nbsp;
<asp:DropDownList runat="server" ID="ddlCategory" AppendDataBoundItems="True">
</asp:DropDownList>
&nbsp;
<asp:DropDownList runat="server" ID="ddlSegment" AppendDataBoundItems="True">
</asp:DropDownList>
&nbsp;
<asp:Button runat="server" ID="btnSearhProjects" Text="Go" 
    CausesValidation="False" onclick="btnSearhProjects_Click" UseSubmitBehavior="False" />

And here is the C# code behind for the button:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCountries();
            BindCategories();
            BindSegments();
            BindStructures();

        }



    }
public void SearchProjects()
    {
        Project project = new Project();
        string country = ddlCountry.SelectedItem.Text;
        string category = ddlCategory.SelectedItem.Text;
        string segment = ddlSegment.SelectedItem.Text;
        string structure = ddlTypeStructure.SelectedItem.Text;
        List<Project> projectList = project.GetProjects(country, category, segment, structure);
        gvProjects.DataSource = projectList;
        gvProjects.DataBind();
    }

    protected void btnSearhProjects_Click(object sender, EventArgs e)
    {
        SearchProjects();
    }

And this is how I am populating each drop down list:

public void BindCountries()
    {
        List<Country> countryList = new List<Country>();
        Country country = new Country();
        countryList = country.GetCountries();

        ddlCountry.DataTextField = "CountryName";
        ddlCountry.DataValueField = "CountryID";
        ddlCountry.DataSource = countryList;
        ddlCountry.DataBind();

    }

I have tried using ddlCountry.SelectedValue.Text and ddlCountry.SelectedItem.Value and they do not work. Any help would be greatly appreciated. Thank you.

  • 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-16T13:50:28+00:00Added an answer on June 16, 2026 at 1:50 pm

    I found the solution to my problem. I had an extra form tag on my master page with method="post". This was causing the page to post back to itself. Once I removed the form tag, I was able to use the drop down lists properly. Thanks.

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

Sidebar

Related Questions

I have multiple asp:button that I created dynamically with jQuery. For each of them,
I have an ASP.NET form with a cancel button that is supposed to, after
I have an ASP.NET GridView that has four columns. The first three are typical
I have an asp.net button to update database <asp:Button ID=btnSave runat=server Text=SaveChanges OnClick=btnSave_Click CssClass=saveButton
I have an asp button that is used to upload images (using uploadify) and
I have a ASP.NET page with an asp:button that is not visible. I can't
i have a asp:button that will fire a delete and want to have a
I have a asp control button that when I look at it in IE
I have a asp gridview with button field column on that button click I
I have an asp.net app with an asp:button that causes a postback, this means

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.