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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:03:09+00:00 2026-06-10T16:03:09+00:00

I have tried below code but it didn’t work: DropDownList1.SelectedIndexChanged += new EventHandler (

  • 0

I have tried below code but it didn’t work:

    DropDownList1.SelectedIndexChanged += new EventHandler ( doSub );
  1. It is in C# not VB
  2. When I type DropDownList1. intellisense doesn’t bring the SelectedIndexChanged method
  3. And last it complains about SelectedIndexChanged is an event and must be called by RaiseEvent

I’m trying to make ddls dynamically based on SelectedValue of each other, so I need to set the OnSelectedIndexChanged values programmatically instead of declarativly like this:

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DoSub">
    </asp:DropDownList>

Thanks in advance.

Tip: Remove the AutoEventWireup=”false” in @Page section to get solution to work.

  • 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-10T16:03:11+00:00Added an answer on June 10, 2026 at 4:03 pm

    Use AddHandler to attach an event handler.

    Syntax:

    AddHandler obj.EventName, AddressOf HandlerName
    

    Example:

    <script runat="server">
        Protected Sub Page_Load(sender As Object, e As System.EventArgs)
            AddHandler DropDownList1.SelectedIndexChanged, AddressOf DoSub
        End Sub
        Sub DoSub(sender As Object, e As System.EventArgs)
            Response.Write(DropDownList1.SelectedValue)
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
    
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                <asp:ListItem>Foo</asp:ListItem>
                <asp:ListItem>Bar</asp:ListItem>
            </asp:DropDownList>
    
        </div>
        </form>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried rectifying the code below. But I am not able to find
I want to open an xlsx file, I have tried the below code,but neither
I have tried using the code below but it only display results in Chrome
I have tried many ways implementing the below example, but I could not make
I want to invoke /etc/init.d/tomcat6 in subprocess. I have tried the below code, but
I have tried searching over the internet about this problem but not able to
I have tried many permutations but they all don't seems to work well. Am
I have the code like below to get 'content' width, but how come it
I want to style mail body. I have tried the below methods to style
I need to echo entire content of included file. I have tried the below:

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.