Gridview validation - almost perfect - but not quite

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guybuk
    New Member
    • Jun 2010
    • 2

    Gridview validation - almost perfect - but not quite

    Hi

    This is a vb (2008) asp site.

    I'm using validators in a gridview control. The columns have been converted to templates and, when editing the data the validation works as expected.

    However, when the gridview first goes into Edit mode, even if the existing data fails validation, the validators don't highlight the errors UNTIL the data has been manually edited and the field loses focus. Only then do the validators correctly show the validation errors.

    How can I programatically force the validators to check the validation and display their messages when the gridview is first displayed, before the data is edited ?

    btw: The validators are warning the user about business rules so it's possible that data from the database may fail validation.

    Cheers - G
  • benwizzle
    New Member
    • May 2010
    • 72

    #2
    Maybe do this inside Gridview.RowEdi ting event
    Code:
    FieldValidator.ControlToValidate = "control"
    FieldValidator.Validate()

    Comment

    • guybuk
      New Member
      • Jun 2010
      • 2

      #3
      Originally posted by benwizzle
      Maybe do this inside Gridview.RowEdi ting event
      Code:
      FieldValidator.ControlToValidate = "control"
      FieldValidator.Validate()
      Thanks benwizle, I had a quick look at this but don't seem to have access to the validation controls, within the gridview, on the page. I tink could get a readonly refrence from GridView1.Contr ols collection but can't call the validate method on that.
      Am I missing something obvious here :o)

      Comment

      • benwizzle
        New Member
        • May 2010
        • 72

        #4
        Sorry it took me so long to respond. I have been quite busy. I will recreate this problem ASAP and see what I can work up. Personally, Ive never had this problem because I dont use the validator controls. I just hardcode all my validation.

        Comment

        Working...