Validator within a Repeater problem

  • Thread starter Thread starter Jerrad
  • Start date Start date
J

Jerrad

I have a textbox and a button within a repeater. The
OnItemCommand sub of the repeater looks like this:

Sub RepeaterButtonSub(ByVal source As Object, ByVal e
As RepeaterCommandEventArgs)
Dim RejectTxt As TextBox =
CType(e.Item.FindControl("txtRejectNote"), TextBox)
RejectButton(New
Guid(e.CommandArgument.ToString), RejectTxt.Text)
End Sub

Note that even though the textbox within each repeateritem
are named the same ("txtRejectNote"), the sub gets the
correct one, I assume because FindControl is limited to
searching for controls within the specific repeateritem.
Now I want to add a RequiredFieldValidator for the textbox.
I set the ControlToValidate to "txtRejectNote", but
instead of validating just the textbox within the
repeateritem in which I clicked the button, it validates
all the textboxes in all the repeateritems (since they all
have the same ID). Is this a bug? Is there any way to
make it validate only the textbox that's in the same
repeateritem as the button? Thanks.
 
ASP.Net validator controls are all or nothing. ASP.Net 2.0 solves this
problem. In the interim there are a number of 3rd party components, such
as: http://www.peterblum.com/vam/home.aspx

That's just one I found by searching, I don't think it's free, but you
should be able to find one. Search for grouped validator controls or
something similar.

Karl
 
That stinks. I've even tried assigning each textbox a
unique ID in the repeater's ItemDataBound event and then
assigning that unique ID to the validator's
ControlToValidate property, but that didn't work either.
 

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

Back
Top