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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:59:37+00:00 2026-06-08T18:59:37+00:00

within an asp.net page I have a predefined drop down menu <asp:DropDownList CssClass=queryterm dropdownSpacer

  • 0

within an asp.net page I have a predefined drop down menu

<asp:DropDownList CssClass="queryterm dropdownSpacer" ID="ddResultNum" runat="server">
     <asp:ListItem Text="10 Results " Value="10" />
     <asp:ListItem Text="20 Results" Value="20" />
     <asp:ListItem Text="30 Results" Value="30" />
     <asp:ListItem Text="40 Results" Value="40" />
     <asp:ListItem Text="50 Results" Value="50" />
     <asp:ListItem Text="100 Results" Value="100" />
</asp:DropDownList>

In the code behind I am trying to set the selected value based upon a query to the database.

protected void SetResultsDropDown()
        {
            string selectCommand = String.Format("SELECT ResultsReturned FROM StoredFilters WHERE SecurityUserID = {0}", securityUserId);
            string resultValue = DatabaseUtilities.QueryDatabase(selectCommand, ConfigurationManager.AppSettings["informconnectstring"].ToString(), "ResultsReturned");
           //based upon the users id the db stores the set number from the drop down the default is 10 however if the number changes when the page loads I want the user to see what their current result set being returned is in the drop down vs. it defaulting to the first option
            ddResultNum.ClearSelection();
            switch (resultValue)
            {
                case "10":   
                    ddResultNum.Items[0].Selected = true; 
                    break;
                case "20":
                    ddResultNum.Items[1].Selected = true; 
                    break;
                case "30":
                    ddResultNum.Items[2].Selected = true;
                    break;
                case "40":
                    ddResultNum.Items[3].Selected =true;
                    break;
                case "50":
                    ddResultNum.Items[4].Selected = true;
                    break;
                case "100":
                    ddResultNum.Items[5].Selected = true;
                    break;
            }
        }

I have tried calling this method using onInit as well as during the page load

protected override void OnInit( EventArgs e)
        {
            base.OnInit(e);
            // Extract an Inform User ID from the Token.
            IClaimsIdentity claimsIdentity = ((IClaimsPrincipal)(Thread.CurrentPrincipal)).Identities[0];
            securityUserId = Convert.ToInt64(claimsIdentity.Claims.Where(c =>
                c.ClaimType == AuthenticationConstants.INFORM_USER_ID_CLAIM_TYPE).First().Value);

            SetResultsDropDown();
        }

While the switch steps through and updates object I never see the text within the drop down menu update. It always stays set to the first item of 10 results.

I have tried wrapping the control in an udpatepanel and then calling an update on the panel to see if I could force the refresh on render and page load.

I have also tried instead of using Items[0].Selected I have tried to set the selected index as:

protected void SetResultsDropDown()
{
string selectCommand = String.Format("SELECT ResultsReturned FROM StoredFilters WHERE SecurityUserID = {0}", securityUserId);
string resultValue = DatabaseUtilities.QueryDatabase(selectCommand, ConfigurationManager.AppSettings["informconnectstring"].ToString(), "ResultsReturned");
ddResultNum.ClearSelection();
ddResultNum.SelectedIndex = ddResultNum.Items.FindByValue(resultValue);
}

and still no luck. I’d appreciate any help on figuring out why this drop down menu fails to update and represent / display the correct text for what is stored in the database.

-Cheers

  • 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-08T18:59:38+00:00Added an answer on June 8, 2026 at 6:59 pm

    Why don’t you use the DropDownList.SelectedValue property???

    For example:

    ddResultNum.SelectedValue = resultValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used JQuery within my asp.net page. JQuery is working fine. I could
I have an ASP.Net page that contains a <div> with an <img> tag within.
I have an asp.net page within which I've used several AJAX controls doing partial
I have an asp.net page with a multiview control nested within another multiview control.
I have a single-page JavaScript application, held within an ASP.NET MVC 3 website. In
I have an ASP.NET page that uses a repeater nested within another repeater to
I have a devexpress gridview within my asp.net page which has a filter row.
I have an asp.net page with a save button within an updatepanel and contenttemplate.
I have an ASP.NET web page that has an advanced search tab. Within this
Scenario : On a ASP.NET site, we have a login page (login.aspx). Within login.aspx.cs

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.