Re: custom validator controls within a datagrid

Discussion in 'ASP .Net' started by zlusca@gmail.com, Dec 28, 2004.

  1. Guest

    That is really helpful. Thank you very much!

    David Yuan [MS] wrote:
    > Since the Textbox and the Validator is created in the Template, they

    will
    > not appear as the data member of the Page class. Hence you can't add

    event
    > handler for the CustomValidator in the IDE. To add event handler for

    it,
    > you need to write your own code. Below is some sample code on how to

    do it.
    >
    > Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e

    As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    > DataGrid1.ItemCreated
    > 'If e.Item.ItemIndex <> 1 Then Exit Sub
    >
    > Dim c As CustomValidator
    > c = CType(e.Item.Cells(0).FindControl("CustomValidator2"),
    > CustomValidator)
    >
    > If c Is Nothing Then Exit Sub
    >
    > AddHandler c.ServerValidate, AddressOf
    > CustomValidator2_ServerValidate
    > End Sub
    >
    > Private Sub CustomValidator2_ServerValidate(ByVal source As

    Object,
    > ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
    > Debug.WriteLine("server validate")
    > End Sub
    >
    > Hope this helps.
    >
    > David Yuan [MS]
    > This posting is provided "AS IS" with no warranties, and confers no

    rights.
    > "Got .Net? http://www.gotdotnet.com".
     
    , Dec 28, 2004
    #1
    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. user
    Replies:
    1
    Views:
    438
    Kevin Spencer
    Jul 19, 2007
  2. rodchar
    Replies:
    0
    Views:
    397
    rodchar
    Nov 26, 2007
  3. Zoe Hart
    Replies:
    1
    Views:
    373
    Scott Wisniewski
    Jan 8, 2004
  4. Scott Yenor

    How to get custom control to work with custom validator

    Scott Yenor, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    213
    Scott Yenor
    Jan 27, 2004
  5. Erik Cruz

    Custom validator for a pair of controls

    Erik Cruz, Jul 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    130
    Erik Cruz
    Jul 20, 2004
Loading...

Share This Page