By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,781 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,781 IT Pros & Developers. It's quick & easy.

Validator within a Repeater problem

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
"Jerrad" <je*****@oslc.org> wrote in message
news:2f****************************@phx.gbl...
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.

Nov 18 '05 #2

P: n/a
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.
-----Original Message-----
ASP.Net validator controls are all or nothing. ASP.Net 2.0 solves thisproblem. In the interim there are a number of 3rd party components, suchas: http://www.peterblum.com/vam/home.aspx

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

Karl
"Jerrad" <je*****@oslc.org> wrote in message
news:2f****************************@phx.gbl...
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.

.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.