Firing events from drop down list INSIDE a repeater?

Discussion in 'ASP .Net' started by champ.supernova@gmail.com, May 14, 2007.

  1. Guest

    Hi,

    I have a dropdownlist which is repeated inside a repeater. What I'm
    wanting is for when one instance of the dropdownlist has its selection
    changed, for 1) this to trigger an 'OnSelectedIndexChanged'
    subroutine, and 2) for that subroutine to be able to somehow identify
    which 'row' of the repeater the dropdownlist belongs to.

    To keep things simple, I'm posting just the relevant parts of the code
    below...

    (SNIP - Aspx Page)

    <asp:Repeater ID="repProducts" runat="server" DataSource='<
    %#Container.DataItem.Row.GetChildRows("relTypesProducts")%>'
    OnItemDataBound="subRepeater">
    <ItemTemplate>
    <asp:DropDownList ID="cmbProductType" runat="server"
    DataSourceID="sqlProductType" OnSelectedIndexChanged = "subTest"
    AutoPostBack="true">
    </asp:DropDownList>
    </ItemTemplate>
    </asp:Repeater>


    (SNIP - Code Behind)

    Public Sub subTest(ByVal sender As Object, ByVal e As
    System.EventArgs)
    Label1.Text = "Event fired OK"
    ' Other VB Code to go here

    End Sub

    (SNIP)


    My two questions are:

    1. In the first instance, I can't seem to get the event to fire, and
    am wondering if this has something to do with the fact that this is
    inside a repeater. Does anyone know if there is a specific way of
    handling events for controls inside a repeater?

    2. How would I identofy the 'row' of the repeater that the ddl is in?
    I know that with a textbox you can specify a CommandArgument, but
    there is no such thing for ddls. Also I've read that I may need to
    reference the 'parent' element of the ddl, which would be the repeater
    itself. I guess this would mean that the eventargs and so on would be
    repeater ones as opposed to system ones?

    If anyone could point me in the right direction with this I'd be very
    grateful! (I'm using VB rather than C# btw.)
     
    , May 14, 2007
    #1
    1. Advertising

  2. Guest

    I've literally just come across an article saying I need to set the
    EnableViewState of the Repeater to False, and rebind the repeater
    every page load...which sees to make the event fire.

    Will now try to figure out how to get the 'Parent' information...


    On 14 May, 12:50, wrote:
    > Hi,
    >
    > I have a dropdownlist which is repeated inside a repeater. What I'm
    > wanting is for when one instance of the dropdownlist has its selection
    > changed, for 1) this to trigger an 'OnSelectedIndexChanged'
    > subroutine, and 2) for that subroutine to be able to somehow identify
    > which 'row' of the repeater the dropdownlist belongs to.
    >
    > To keep things simple, I'm posting just the relevant parts of the code
    > below...
    >
    > (SNIP - Aspx Page)
    >
    > <asp:Repeater ID="repProducts" runat="server" DataSource='<
    > %#Container.DataItem.Row.GetChildRows("relTypesProducts")%>'
    > OnItemDataBound="subRepeater">
    > <ItemTemplate>
    > <asp:DropDownList ID="cmbProductType" runat="server"
    > DataSourceID="sqlProductType" OnSelectedIndexChanged = "subTest"
    > AutoPostBack="true">
    > </asp:DropDownList>
    > </ItemTemplate>
    > </asp:Repeater>
    >
    > (SNIP - Code Behind)
    >
    > Public Sub subTest(ByVal sender As Object, ByVal e As
    > System.EventArgs)
    > Label1.Text = "Event fired OK"
    > ' Other VB Code to go here
    >
    > End Sub
    >
    > (SNIP)
    >
    > My two questions are:
    >
    > 1. In the first instance, I can't seem to get the event to fire, and
    > am wondering if this has something to do with the fact that this is
    > inside a repeater. Does anyone know if there is a specific way of
    > handling events for controls inside a repeater?
    >
    > 2. How would I identofy the 'row' of the repeater that the ddl is in?
    > I know that with a textbox you can specify a CommandArgument, but
    > there is no such thing for ddls. Also I've read that I may need to
    > reference the 'parent' element of the ddl, which would be the repeater
    > itself. I guess this would mean that the eventargs and so on would be
    > repeater ones as opposed to system ones?
    >
    > If anyone could point me in the right direction with this I'd be very
    > grateful! (I'm using VB rather than C# btw.)
     
    , May 14, 2007
    #2
    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. Guest

    Drop down list inside a repeater

    Guest, Dec 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    14,709
    Hatim R
    Dec 5, 2003
  2. SirPoonga
    Replies:
    2
    Views:
    803
    Ben Strackany
    Jan 7, 2005
  3. weiwei
    Replies:
    0
    Views:
    1,050
    weiwei
    Jan 5, 2007
  4. Jeremy  Mack

    drop down list in repeater not firing?

    Jeremy Mack, Nov 8, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    182
    Jeremy Mack
    Nov 8, 2005
  5. Replies:
    5
    Views:
    302
Loading...

Share This Page