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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:25:31+00:00 2026-05-26T21:25:31+00:00

I have a bit of trouble with getting dropdownlist selected value we have in

  • 0

I have a bit of trouble with getting dropdownlist selected value we have in aspx a Gridview and in it dropdownlist:

<asp:GridView ID="grid1" runat="server" autogeneratecolumns="true" >
    <Columns>
        <asp:BoundField HeaderText="something" />
        <asp:TemplateField HeaderText="filtras">
            <HeaderTemplate>
                <asp:DropDownList ID="dropdown1" runat="server"
                    OnLoad="dropdownLoad"
                    OnSelectedIndexChanged="updatetable" />
            </HeaderTemplate>
         </asp:TemplateField>
    </Columns>
</asp:GridView>

We fill the DropDownList with values using OnLoad event, and then when we select something from the DropDownList, the event OnSelectedIndexChange should allow us to take the selected value and to do what we want with it (filter the grid in this case), but OnSelectedIndexChange never gets executed.

protected void Page_Load(object sender, EventArgs e)
{ 
    //Create Gridview + fill with values
    if (IsPostBack)
    {
        return;
    }

    ArrayList mycountries = new ArrayList();
    mycountries.Add("Norway");
    mycountries.Add("Sweden");
    mycountries.Add("France");
    mycountries.Add("Italy");
    mycountries.TrimToSize();
    mycountries.Sort();

    rb.DataSource = mycountries;
    rb.DataBind();

    grid1.DataSource = mycountries;
    grid1.DataBind();
}

protected void dropdownLoad(object sender, EventArgs e)
{   // fill dropDownList in GridView with data
    DropDownList dropdown = sender as DropDownList;
    if (dropdown != null)
    {
        ArrayList mycountries = new ArrayList();
        mycountries.Add("Norway");
        mycountries.Add("Sweden");
        mycountries.Add("France");
        mycountries.Add("Italy");
        mycountries.TrimToSize();
        mycountries.Sort();

        dropdown.DataSource = mycountries;
        dropdown.DataBind();

        TextBox1.Text = dropdown.SelectedIndex.ToString();
    }
}

protected void updatetable(object sender, EventArgs e)
{// after dropDownList element was selected change dropdownlist values/or filter the table...
 //this part is never executed ! Why?

    DropDownList dropdown = sender as DropDownList;
    if (dropdown != null)
    {
        ArrayList mycountries = new ArrayList();
        mycountries.Add("UK");
        mycountries.Add("USA");
        mycountries.Add("Sweden");
        mycountries.Add("Hungary");
        mycountries.TrimToSize();
        mycountries.Sort();

        dropdown.DataSource = mycountries;
        dropdown.DataBind();
    }
}

How can I get the DropDownList‘s selected value? My debugger shows that OnSelectedIndexChange is never executed.
I tried following the suggestions in this question Setting selectedvalue for a dropdownlist in GridView, but that didn’t 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-05-26T21:25:32+00:00Added an answer on May 26, 2026 at 9:25 pm

    Have you tried setting AutoPostBack to true for your dropdown control so that it causes a postback?

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

Sidebar

Related Questions

I am having a little bit of trouble getting my aspx pages to recognize
Following this question and answer , I still have a bit trouble in the
Having a bit of trouble using the List.Find with a custom predicate i have
I'm having a bit of trouble loading pages into an already-existing colorbox. I have
I'm a bit in IDE trouble, and I'm not alone I have noticed, still
I'm a bit new to SQL and have trouble constructing a select statement. I
I'm having a bit of trouble getting the right results from a query. At
iI have some trouble getting sth like this to work in java: public class
I have a little trouble getting gettext to work. I made a simple test
I'm having a bit of trouble getting a SQL query to work. Some background

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.