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

The Archive Base Latest Questions

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

I have this in my page: <asp:DropDownList ID=membros runat=server> </asp:DropDownList> and in the code

  • 0

I have this in my page:

<asp:DropDownList ID="membros" runat="server">
</asp:DropDownList>

and in the code behind, I have this:

        protected void Page_Load(object sender, EventArgs e)
        {
            members.Items.Clear();
            members.Items.Add(new ListItem("Choose...", ""));

            foreach (DataRow item in com.Execute("select * from tableMembers").Rows)
            {
                 members.Items.Add(new ListItem(item["name"].ToString(), item["id_user"].ToString()));
                 contForeach++;
            }
        }

and when I try to get the value from SelectedIndex I can’t because he always get me 0 independently of what index I choose.

  • 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-17T22:50:28+00:00Added an answer on June 17, 2026 at 10:50 pm

    put that in if(!IsPostBack) so that it can load the dropdown at first time the form loads,right now it is loading everytime the page loads so your missing your selection.

          if(!IsPostBack)
          {
            members.Items.Clear();
            members.Items.Add(new ListItem("Choose...", ""));
    
            foreach (DataRow item in com.Execute("select * from tableMembers").Rows)
            {
                 members.Items.Add(new ListItem(item["name"].ToString(),           item["id_user"].ToString()));
                 contForeach++;
            }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code on an aspx page. <asp:DropDownList runat=server ID=ddlSize CssClass=textbox Width=100px> <asp:ListItem
I have a search.aspx page that has this: <asp:DropDownList id=ddlPopulation runat=server DataTextField=population DataValueField=pid> </asp:DropDownList>
In code-behind of an ASP.NET page I have this method: public string TestFunc() {
I have my asp.net sub-master page setup like this: <asp:Content ID=MainContent runat=server ContentPlaceHolderID=mainContent> <!doctype
I have a databound dropdownlist on my asp.net page. <asp:DropDownList ID=ddlCases runat=server></asp:DropDownList> I am
I have a dropdownlist like this <asp:dropdownlist runat=server autopostback=true onselecteditemindexchanged=fire_event ID=DDL/> and on codebehind
I have an asp.net dropdown like this <asp:DropDownList width=95% ID=RessourceComposantes runat=server DataSourceID=Composantes DataTextField=Description DataValueField=ComposanteID>
I have following codes in asp.net: <asp:dropdownlist id=ddlApp runat=server /> <asp:button id=btnSmt runat=server Text=Submit
I have two dropdown lists: <asp:DropDownList ID=Field_Type runat=server /> <asp:DropDownList ID=Field_SubType runat=server /> Field_Type
So I have a Web Forms asp control: <asp:DropDownList runat=server ID=ExistingTemplate ClientIDMode=Static /> On

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.