468,272 Members | 2,159 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Repeater Control Question

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

Nov 18 '05 #1
1 1228
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

"Z D" <NO****@NOSPAM.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Fraggle | last post: by
4 posts views Thread by MattB | last post: by
1 post views Thread by olduncleamos | last post: by
7 posts views Thread by charliewest | last post: by
3 posts views Thread by Andrew | last post: by
12 posts views Thread by =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.