Re: How to capture SelectedIndexchanged event of dropdownlist in Datagrid

Discussion in 'ASP .Net' started by Shiva, Oct 31, 2004.

  1. Shiva

    Shiva Guest

    Use the OnSelectedIndexChanged attribute of the <asp:DropDownList> element
    to hook to your server-side event.

    Eg:

    In .aspx file:
    ....
    <EditItemTemplate>
    <asp:DropDownList id="ddl" runat=server
    OnSelectedIndexChanged="SelectionChanged" />
    <EditItemTemplate>
    ....

    In code-behind file:

    //C#
    protected void SelectionChanged (object sender, EventArgs e)
    {
    DropDownList d = (DropDownList)sender;
    // Use d here
    }

    HTH.

    (Type your message here)

    --------------------------------
    From: Uma Shanmugam

    Everyone,
    I have a datagrid and it has a dropdownlist in the Edit mode.I want to
    capture the selectedIndexChanged event of the dropdownlist. I tried
    ItemCommand event and then realised that it is fired when a button is
    clicked.Any help will be greatly appreciated.

    Thanks in Advance
    Uma Shanmugam
     
    Shiva, Oct 31, 2004
    #1
    1. Advertisements

  2. Shiva

    Guest Guest

    Hi Shiva,

    Yes, selectchanged is captured. But the SelectedItemIndex still remain
    without change. Any Idea?

    Yuki
     
    Guest, Feb 25, 2005
    #2
    1. Advertisements

  3. Shiva

    Jc Morin Guest

    Did you assign the value in the Page_Load event ? maybe you didn't set the
    routine in

    if (!IsPostBack) {

    }

    so after postback the original value is re-apply before you read the value
    again...
     
    Jc Morin, Feb 25, 2005
    #3
  4. Shiva

    leoykl

    Joined:
    Jun 14, 2012
    Messages:
    1
    Likes Received:
    0
    did u set the autopostback to true ??


    <asp:DropDownList ID="ddlProductType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlProductType_SelectedIndexChanged">
    </asp:DropDownList>





     
    leoykl, Jun 14, 2012
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.