C
champ.supernova
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>
<aspropDownList ID="cmbProductType" runat="server"
DataSourceID="sqlProductType" OnSelectedIndexChanged = "subTest"
AutoPostBack="true">
</aspropDownList>
</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.)
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>
<aspropDownList ID="cmbProductType" runat="server"
DataSourceID="sqlProductType" OnSelectedIndexChanged = "subTest"
AutoPostBack="true">
</aspropDownList>
</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.)