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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:31:08+00:00 2026-06-16T03:31:08+00:00

I have a dropdown list in User Control How Can I get selected value

  • 0

I have a dropdown list in User Control

How Can I get selected value of dropdown list of user control in page when user select another item (auto postback is true)?

I tried to store selected value of ddl in a public member from Selected Index Changed event handler. But this handler executes after page load of container page. I need to load data in page based on selected value in ddl of user control.

Thanks

User Control’s code

protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)

{

        _SelectedPageSize = Convert.ToInt32(ddlPageSize.SelectedValue);

}



int GetSelectedPageSize()

{

       return _SelectedPageSize;
}
  • 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-16T03:31:10+00:00Added an answer on June 16, 2026 at 3:31 am

    There are a number of ways to accomplish what you’re looking for. The first is simply to re-order your events in the containing page. If you use the PreRender event rather than the PageLoad event, your drop down selection action will be complete and the information will be readily available.

    A second method, which probably more extensible, would be to raise a custom event from your usercontrol that your page listens for and handles. Then the action would be taken directly at the point where the information is immediately available. This allows any containing structure (whether it’s a page, usercontrol or something similar) to subscribe to the event and handle whatever is needed.

    A third method, a little more rigid, would be to have a function in the containing page that is called by the usercontrol once the data is complete. This requires the usercontrol to have knowledge of the specific page type that it will be included in (making it less extensible) so I wouldn’t recommend it.

    Edit: Here’s an idea for implement option #2 with a custom event:

    public partial class MyUserControl: UserControl
    {
        //All of your existing code goes in here somewhere
    
        //Declare an event that describes what happened. This is a delegate
        public event EventHandler PageSizeSelected;
    
    
        //Provide a method that properly raises the event
        protected virtual void OnPageSizeSelected(EventArgs e)
        {
            // Here, you use the "this" so it's your own control. You can also
            // customize the EventArgs to pass something you'd like.
    
            if (PageSizeSelected!= null)
                PageSizeSelected(this, e);
        }
    
        private void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            _SelectedPageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
            OnPageSizeSelected(EventArgs.Empty);
        }
    }
    

    Then in your page code you would listen for the event. Somewhere in the page load you would add:

    myUserControlInstance.PageSizeSelected += MyHandinglingMethod;
    

    And then provide the method that handles the event:

    protected void MyHandlingMethod(object sender, EventArgs e)
    {
        // Do what you need to do here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop-down list hardcoded in an MVC View User Control page and
I have an ASP.NET DropDownList control that renders into a dropdown list (select HTML
I have a user control on a page and I'd like to load another
I have a winform containing a DropDown combobox, where the user can enter a
I have a page (category-list.apsx) that uses the Repeater Control method to display the
I have a page that that contains a User Control and a submit Button.
I have a page that contains a user control that is just a personalized
I have a web user control with a dropdownlist inside of it. When the
I have asp:DropDownList control which i want to display data to user who don't
I have a RequiredFieldValidator on one of my DropDownLists in my user control. The

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.