Results 1 to 8 of 8

Thread: how to perform validation on textbox in templatecolumn of datagrid?

Hybrid View

  1. #1
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to perform validation on textbox in templatecolumn of datagrid?

    OK, a few changes to what I said.

    Instead of

    validator.ControlToValidate = txtbox.ClientID

    put

    validator.ControlToValidate = txtbox

    That should do it.

    Btw, you never said what the error was, but try what I just said right now.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: how to perform validation on textbox in templatecolumn of datagrid?

    That won't work - the ControlToValidate property expects a string, not a control class object.

    You never stated what the error was, but you need the UniqueID property.

    validator.ControlToValidate = txtbox.UniqueID.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    Re: how to perform validation on textbox in templatecolumn of datagrid?

    The error is
    Code:
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    
    Source Error: 
    
    
    Line 613:        txtbox = CType(e.Item.FindControl("textbox"), System.Web.UI.WebControls.TextBox)
    Line 614:       
    Line 615:        validator.ControlToValidate = txtbox.UniqueID

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to perform validation on textbox in templatecolumn of datagrid?

    Quote Originally Posted by nemaroller
    That won't work - the ControlToValidate property expects a string, not a control class object.

    You never stated what the error was, but you need the UniqueID property.

    validator.ControlToValidate = txtbox.UniqueID.
    My bad, but not-so-bad, I had no IDE and Intellisense

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width