Gridview error handling

Discussion in 'ASP .Net Web Controls' started by Arne Garvander, Nov 12, 2007.

  1. I have a gridview control that is updateable. One of the data elements is
    date, which is very easy to misstype. An invalid date will throw an error. Is
    there a way to handle that error in a neat and clean manner?
    --
    Arne Garvander
    Certified Geek
    Professional Data Dude
    Arne Garvander, Nov 12, 2007
    #1
    1. Advertising

  2. Arne Garvander

    Manish Bafna Guest

    Hi,
    Try placing necessary validator controls in the edit template
    --
    Hope this helps.
    Thanks and Regards.
    Manish Bafna.
    MCP and MCTS.



    "Arne Garvander" wrote:

    > I have a gridview control that is updateable. One of the data elements is
    > date, which is very easy to misstype. An invalid date will throw an error. Is
    > there a way to handle that error in a neat and clean manner?
    > --
    > Arne Garvander
    > Certified Geek
    > Professional Data Dude
    Manish Bafna, Nov 13, 2007
    #2
    1. Advertising

  3. Gridview error handling Date + time

    Thanks for the tip.
    I can get the validator to validate a date, but if I add time to the date,
    the validator will missfire.
    In a regular form I can validate a date+time, but not in a gridview template.

    --
    Arne Garvander
    Certified Geek
    Professional Data Dude


    "Manish Bafna" wrote:

    > Hi,
    > Try placing necessary validator controls in the edit template
    > --
    > Hope this helps.
    > Thanks and Regards.
    > Manish Bafna.
    > MCP and MCTS.
    >
    >
    >
    > "Arne Garvander" wrote:
    >
    > > I have a gridview control that is updateable. One of the data elements is
    > > date, which is very easy to misstype. An invalid date will throw an error. Is
    > > there a way to handle that error in a neat and clean manner?
    > > --
    > > Arne Garvander
    > > Certified Geek
    > > Professional Data Dude
    Arne Garvander, Nov 13, 2007
    #3
  4. Arne Garvander

    Phil H Guest

    Re: Gridview error handling Date + time

    On 13 Nov, 15:56, Arne Garvander
    <> wrote:
    > Thanks for the tip.
    > I can get the validator to validate a date, but if I add time to the date,
    > the validator will missfire.
    > In a regular form I can validate a date+time, but not in a gridview template.
    >
    > --
    > Arne Garvander
    > Certified Geek
    > Professional Data Dude
    >
    >
    >
    > "Manish Bafna" wrote:
    > > Hi,
    > > Try placing necessary validator controls in the edit template
    > > --
    > > Hope this helps.
    > > Thanks and Regards.
    > > Manish Bafna.
    > > MCP and MCTS.

    >
    > > "Arne Garvander" wrote:

    >
    > > > I have a gridview control that is updateable. One of the data elements is
    > > > date, which is very easy to misstype. An invalid date will throw an error. Is
    > > > there a way to handle that error in a neat and clean manner?
    > > > --
    > > > Arne Garvander
    > > > Certified Geek
    > > > Professional Data Dude- Hide quoted text -

    >
    > - Show quoted text -


    The alternative is to place validation code in the
    GridView.RowUpdating event. There you can use DateTime parsing and any
    other checks you wish to make. If the validation fails then the event
    argument e (GridViewUpdateEventArgs.Cancel) can be used to abort the
    update and return the grid to the edit view (using label controls for
    error messages).

    HTH
    Phil H, Nov 17, 2007
    #4
  5. Re: Gridview error handling Date + time

    That doesn't work.
    --
    Arne Garvander
    Certified Geek
    Professional Data Dude


    "Phil H" wrote:

    > On 13 Nov, 15:56, Arne Garvander
    > <> wrote:
    > > Thanks for the tip.
    > > I can get the validator to validate a date, but if I add time to the date,
    > > the validator will missfire.
    > > In a regular form I can validate a date+time, but not in a gridview template.
    > >
    > > --
    > > Arne Garvander
    > > Certified Geek
    > > Professional Data Dude
    > >
    > >
    > >
    > > "Manish Bafna" wrote:
    > > > Hi,
    > > > Try placing necessary validator controls in the edit template
    > > > --
    > > > Hope this helps.
    > > > Thanks and Regards.
    > > > Manish Bafna.
    > > > MCP and MCTS.

    > >
    > > > "Arne Garvander" wrote:

    > >
    > > > > I have a gridview control that is updateable. One of the data elements is
    > > > > date, which is very easy to misstype. An invalid date will throw an error. Is
    > > > > there a way to handle that error in a neat and clean manner?
    > > > > --
    > > > > Arne Garvander
    > > > > Certified Geek
    > > > > Professional Data Dude- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > The alternative is to place validation code in the
    > GridView.RowUpdating event. There you can use DateTime parsing and any
    > other checks you wish to make. If the validation fails then the event
    > argument e (GridViewUpdateEventArgs.Cancel) can be used to abort the
    > update and return the grid to the edit view (using label controls for
    > error messages).
    >
    > HTH
    >
    Arne Garvander, Nov 19, 2007
    #5
  6. Arne Garvander

    slam radio Guest

    gridview date + time error handling

    Try this, it works! :)

    Private Sub GridView1_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles gvSchedule.RowUpdated
    If e.Exception IsNot Nothing Then
    ErrorMessageLabel.Text = e.Exception.Message
    e.ExceptionHandled = True
    e.KeepInEditMode = True
    End If
    End Sub

    EggHeadCafe - .NET Developer Portal of Choice
    http://www.eggheadcafe.com
    slam radio, Nov 21, 2007
    #6
    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. =?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,944
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  2. Joe Kovac

    GridView and nice Error-Handling

    Joe Kovac, Jun 4, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    320
    Joe Kovac
    Jun 4, 2007
  3. Mark Tarver
    Replies:
    22
    Views:
    1,274
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,911
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    174
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page