Repeater Control Question

  • Thread starter Thread starter Z D
  • Start date Start date
Z

Z D

Hello,

I have a checkbox control as one of the items within my repeater control.

I've set the AutoPostBack=True on the checkbox.

How do I access the event (so that I can run some code) whenever someone
clicks on the checkbox? Also, how do I determine which checkbox was clicked
so that I can run the appropriate code?

thanks in advance,
-ZD
 
I recently did a similar task with a repeater. When using a repeater, it
will rename the controls within it so they have uniqe ID's.
Here's a basic example:

RepeaterName__ctrl00_ControlName

ctrl00 is how many times it's looped through.

I had a button within a repeater, and this is how I found out what buttons
was pressed:


<asp:button cssclass="BoxType42" value="Allow" id="btnAllow" name="Allow"
Text="DisAllow" onclick="SwitchItem" runat="server" />

Code Behind:

Public Sub SwitchItem(ByVal sender As System.Object, ByVal e As
System.EventArgs)
'**Let's say the item passed in was Repeater1__ctrl01_btnSubmit
Dim btnTest As New Button
Dim astrTest As String()
btnTest = CType(sender, Button)
astrTest = btnTest.ClientID.Split("_")
strControlsToEdit = astrTest(2)
....
End Sub

At the end, strControlsToEdit will contain ctrol01 (telling me what loop to
look for if I need to edit anything special within that one section of the
repeater).
astrTest(3) will give you "btnSubmit".


If you need to loop through all items, look at the post started on July 23,
2004 by me and read the responses to it.

Hope this helps.

Ryan Ternier
Code Monkey
 
Back
Top