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

  • Home
  • SEARCH
  • 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 4065268
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:57:42+00:00 2026-05-20T15:57:42+00:00

I am trying to capture the SelectedIndexChanged event for a drop down list I

  • 0

I am trying to capture the SelectedIndexChanged event for a drop down list I have put inside of a gridview control. It posts back fine, but does not go into my SelectedIndexChanged event handler. Here is my code

    DropDownList myddl;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.myGridview.RowDataBound += new GridViewRowEventHandler(myGridview_RowDataBound);
        myddl = new DropDownList();
        myddl.SelectedIndexChanged += new EventHandler(myddl_SelectedIndexChanged);
        if (!Page.IsPostBack)
        {
            List<Team> teams = giveMeTeams();
            this.myGridview.DataSource = teams;
            this.myGridview.AutoGenerateColumns = false;

            BoundField col1 = new BoundField();
            col1.DataField = "Name";
            this.myGridview.Columns.Add(col1);

            BoundField col2 = new BoundField();
            col2.DataField = "Sport";
            this.myGridview.Columns.Add(col2);

            BoundField col3 = new BoundField();
            col3.DataField = "Status";
            this.myGridview.Columns.Add(col3);

            this.myGridview.DataBind();
        }
    }

    void myGridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        myddl = new DropDownList();
        myddl.SelectedIndexChanged += new EventHandler(myddl_SelectedIndexChanged);
        List<string> items = new List<string>();
        items.Add("good");
        items.Add("bad");
        myddl.DataSource = items;
        myddl.AutoPostBack = true;
        myddl.DataBind();
        e.Row.Cells[2].Controls.Add(myddl);
    }

    void myddl_SelectedIndexChanged(object sender, EventArgs e)
    {
        string temp = "In Here";  //neve hits this code
    }

    private List<Team> giveMeTeams()
    {
        Teams teams = new Teams();
        teams.Add(new Team("RedWings", "Hockey", "good"));
        teams.Add(new Team("Lions", "Football", "bad"));
        teams.Add(new Team("Packers", "Football", "good"));
        return teams;
    }

Any help is greatly appreciated.
Thanks,

Edited based on Comments

I have tried as you suggested…and am still not capturing the post back. here is my new code

        void myGridview_RowCreated(object sender, GridViewRowEventArgs e)
    {
        DropDownList myddl = new DropDownList();
        myddl = new DropDownList();
        myddl.SelectedIndexChanged += new EventHandler(myddl_SelectedIndexChanged);
        myddl.ID = "MyID" + e.Row.RowIndex.ToString();
        e.Row.Cells[2].Controls.Add(myddl);
    }

    void myGridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DropDownList myddl = e.Row.FindControl("MyID" + e.Row.RowIndex.ToString()) as DropDownList;
        //myddl.SelectedIndexChanged += new EventHandler(myddl_SelectedIndexChanged);
        List<string> items = new List<string>();
        items.Add("good");
        items.Add("bad");
        myddl.DataSource = items;
        myddl.DataMember = "Status";
        myddl.AutoPostBack = true;
        myddl.DataBind();
        e.Row.Cells[2].Controls.Add(myddl);
    }

it is still not going into my myddl_SelectedIndexChanged() eventhandler.

  • 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-05-20T15:57:43+00:00Added an answer on May 20, 2026 at 3:57 pm

    Create that Dropdownlist in RowCreated of the Grid and assign an ID to it. Get the refrence to these Dropdowns in RowDataBound via e.Row.FindControl("MyDropdownlistID") and bound them to the Datasource. Create distinct Dropdownlist instances instead of referencing always the same

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

Sidebar

Related Questions

I'm trying to capture the TouchRelease event in Android. I have seen that event.getAction()
I'm trying to capture the ENTER event of a TextInput like so: a_txt.addEventListener(fl.events.ComponentEvent.ENTER, aEnter);
I'm trying to capture packets from two devices on my network. I have tcpdump
I have these form values I'm trying capture in a session: prop_zip prop_st address
I have been trying to capture stdout and stderr output from a DLL compiled
I am trying to capture the first string from a list using an explicit
I am trying to capture Window's active window changed event. Let's say if user
I'm trying to capture the event when the user clicks an Android Market url
I am trying to capture any keystroke that happens inside my Silverlight 2 application.
Problem: I am trying to capture click event of the ImageButton. I am not

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.