Firing events from drop down list INSIDE a repeater?

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

champ.supernova

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

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top