TextBox Validation Inside a Repeater

Discussion in 'ASP .Net' started by =?Utf-8?B?QnJ5YW4=?=, Aug 20, 2004.

  1. I trying to figure out out to validate a textbox inside a repeater once a
    person presses a button on a repeater.

    Here's the validation Code behind:

    Please be aware that line e.Item.ItemIndex is invalid. Because I don't know
    how to pass the repeater as the object through the OnServerValidate Tag in
    the ASP.NET side. What I really need is to pull the ItemIndex from the
    actual repeater.

    Sub ValidQtyValidation(ByVal source As Object, ByVal args As
    ServerValidateEventArgs)

    'Counts the rows of the collection
    Dim i As Integer
    'Get the the row of the repeater that the button was pushed
    i = e.Item.ItemIndex
    'Grabs the information out the text box dependent on the index
    number in the repeater
    txtbox = CType(rptItemDescription.Items(i).FindControl("txtQty"),
    TextBox)
    'Validation check
    If IsNumeric(txtbox.Text) = False Then
    args.IsValid = False
    Else
    args.IsValid = True
    End If
    End Sub
    =?Utf-8?B?QnJ5YW4=?=, Aug 20, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?QnJ5YW4=?=

    Karl Guest

    can't you just use args.value to get the textbox value? assuming you set the
    controltovalidate properly..should be go..

    args.IsValid = IsNumeric(args.Value)

    Karl


    "Bryan" <> wrote in message
    news:...
    > I trying to figure out out to validate a textbox inside a repeater once a
    > person presses a button on a repeater.
    >
    > Here's the validation Code behind:
    >
    > Please be aware that line e.Item.ItemIndex is invalid. Because I don't

    know
    > how to pass the repeater as the object through the OnServerValidate Tag in
    > the ASP.NET side. What I really need is to pull the ItemIndex from the
    > actual repeater.
    >
    > Sub ValidQtyValidation(ByVal source As Object, ByVal args As
    > ServerValidateEventArgs)
    >
    > 'Counts the rows of the collection
    > Dim i As Integer
    > 'Get the the row of the repeater that the button was pushed
    > i = e.Item.ItemIndex
    > 'Grabs the information out the text box dependent on the index
    > number in the repeater
    > txtbox = CType(rptItemDescription.Items(i).FindControl("txtQty"),
    > TextBox)
    > 'Validation check
    > If IsNumeric(txtbox.Text) = False Then
    > args.IsValid = False
    > Else
    > args.IsValid = True
    > End If
    > End Sub
    >
    >
    Karl, Aug 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. guoqi zheng
    Replies:
    1
    Views:
    3,317
    Teemu Keiski
    Jun 10, 2005
  2. Replies:
    1
    Views:
    7,014
    Karl Seguin
    Aug 10, 2005
  3. Replies:
    2
    Views:
    18,610
    JohnnyC
    Aug 8, 2011
  4. uncensored
    Replies:
    0
    Views:
    801
    uncensored
    Oct 25, 2006
  5. Microsoft

    Repeater inside a Repeater

    Microsoft, Aug 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    196
    Microsoft
    Aug 21, 2006
Loading...

Share This Page