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.

    "Uma Shanmugam via .NET 247" <> wrote in message
    news:ePbg9$...
    (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

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>/ZIKIJ+ZZkqlTW/OJYF/Cg==</Id>
     
    Shiva, Oct 31, 2004
    #1
    1. Advertising

  2. Re: How to capture SelectedIndexchanged event of dropdownlist in D

    Hi Shiva,

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

    Yuki

    "Shiva" wrote:

    > 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.
    >
    > "Uma Shanmugam via .NET 247" <> wrote in message
    > news:ePbg9$...
    > (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
    >
    > -----------------------
    > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    > <Id>/ZIKIJ+ZZkqlTW/OJYF/Cg==</Id>
    >
    >
    >
     
    =?Utf-8?B?WXVraQ==?=, Feb 25, 2005
    #2
    1. Advertising

  3. Shiva

    Jc Morin Guest

    Re: How to capture SelectedIndexchanged event of dropdownlist in D

    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...

    --------------------------
    Jean-Claude Morin, MCP
    Software Developer
    2k1Soft/kCentric, Canada


    "Yuki" <> wrote in message
    news:...
    > Hi Shiva,
    >
    > Yes, selectchanged is captured. But the SelectedItemIndex still remain
    > without change. Any Idea?
    >
    > Yuki
    >
    > "Shiva" wrote:
    >
    > > 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.
    > >
    > > "Uma Shanmugam via .NET 247" <> wrote in message
    > > news:ePbg9$...
    > > (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
    > >
    > > -----------------------
    > > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    > >
    > > <Id>/ZIKIJ+ZZkqlTW/OJYF/Cg==</Id>
    > >
    > >
    > >
     
    Jc Morin, Feb 25, 2005
    #3
  4. Shiva

    leoykl

    Joined:
    Jun 14, 2012
    Messages:
    1
    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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shiva
    Replies:
    0
    Views:
    449
    Shiva
    Nov 17, 2004
  2. Arthur Dent
    Replies:
    0
    Views:
    545
    Arthur Dent
    Dec 23, 2004
  3. The Colonel
    Replies:
    0
    Views:
    571
    The Colonel
    Jan 24, 2005
  4. The Colonel
    Replies:
    0
    Views:
    518
    The Colonel
    Jan 24, 2005
  5. The Colonel
    Replies:
    0
    Views:
    513
    The Colonel
    Jan 24, 2005
Loading...

Share This Page