Results 1 to 4 of 4

Thread: [2005] validation in edit mode in a GridView

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    19

    [2005] validation in edit mode in a GridView

    Hi all,

    I have a gridview that can edit data, which is bound to an
    sqldatasource. Everything works fine, I can update the data via an Edit
    Command field (not in a template field).
    However, there are some textboxes in edit mode which I would like to
    validate. For example, one of the is required and cannot be left empty.
    How can I make such validation in edit mode in a gridview?

    Thanks in advance,

    Manu

  2. #2
    Lively Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    122

    Re: [2005] validation in edit mode in a GridView

    are the textboxes in the datagrid itself?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    19

    Re: [2005] validation in edit mode in a GridView

    Yes... its in datagrid. But i never place a textbox in datagrid. The bound fields become text box when i clicked update command field.

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] validation in edit mode in a GridView

    As they're supposed to.

    Change the required fields to template fields, and add RequiredFieldValidator controls in each field. Assign the text box as the ControlToValidate for each validator. I'm not sure if VS automatically handles the default update commands with validations... if not, create your own update command and put all your code in a simple if statement:
    If Page.IsValid Then
    'update
    End If

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