Validation in Gridview - ASP.NET

Discussion in 'ASP .Net Web Controls' started by Guido Pederzini, Aug 4, 2008.

  1. Hi all,
    my problem is in the validation of a textbox in a gridview. I have to check
    a quantity that must be a positive number greater than zero.

    In the XML I have used in a ItemTemplate a TextBox with
    1) RequiredFieldValidator (for the existence)
    2) CompareValidator (for the positive number)
    3) RegularExpressionValidator (it's must be a number)

    The problem is that when I fire the "OnClick" event , all the textbox in the
    gridview display the error message associated to the failed validation, and I
    want that only the row in which I have clicked display it.

    I've found a workaround, in the code behind i check all the rules and I
    display an alert with Javascript, but I would know if it's possible to
    control, with the asp.net validator, only the row that fired the onclick
    event.

    Any help will be appreciated. Thanks!
    Guido Pederzini
    Guido Pederzini, Aug 4, 2008
    #1
    1. Advertising

  2. You can put each control in its own validation group.

    "Guido Pederzini" <Guido > wrote in
    message news:...
    > Hi all,
    > my problem is in the validation of a textbox in a gridview. I have to
    > check
    > a quantity that must be a positive number greater than zero.
    >
    > In the XML I have used in a ItemTemplate a TextBox with
    > 1) RequiredFieldValidator (for the existence)
    > 2) CompareValidator (for the positive number)
    > 3) RegularExpressionValidator (it's must be a number)
    >
    > The problem is that when I fire the "OnClick" event , all the textbox in
    > the
    > gridview display the error message associated to the failed validation,
    > and I
    > want that only the row in which I have clicked display it.
    >
    > I've found a workaround, in the code behind i check all the rules and I
    > display an alert with Javascript, but I would know if it's possible to
    > control, with the asp.net validator, only the row that fired the onclick
    > event.
    >
    > Any help will be appreciated. Thanks!
    > Guido Pederzini
    randy.buchholz, Aug 8, 2008
    #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. Colin Mackay
    Replies:
    0
    Views:
    2,678
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,484
  3. Matt
    Replies:
    14
    Views:
    4,072
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  4. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,945
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  5. Sudip
    Replies:
    0
    Views:
    187
    Sudip
    Jul 1, 2005
Loading...

Share This Page