Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / November 2007

Tip: Looking for answers? Try searching our database.

Gridview error handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arne Garvander - 12 Nov 2007 22:37 GMT
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?
Signature

Arne Garvander
Certified Geek
Professional Data Dude

Manish Bafna - 13 Nov 2007 06:04 GMT
Hi,
Try placing necessary validator controls in the edit template
Signature

Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> 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 - 13 Nov 2007 15:56 GMT
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.

Signature

Arne Garvander
Certified Geek
Professional Data Dude

> Hi,
> Try placing necessary validator controls in the edit template
>
> > 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?
Phil H - 17 Nov 2007 16:34 GMT
On 13 Nov, 15:56, Arne Garvander
<ArneGarvan...@discussions.microsoft.com> wrote:
> Thanks for the tip.
> I can get the validator to validate a date, but if I add time to the date,
[quoted text clipped - 23 lines]
>
> - 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 - 19 Nov 2007 14:18 GMT
That doesn't work.
Signature

Arne Garvander
Certified Geek
Professional Data Dude

> On 13 Nov, 15:56, Arne Garvander
> <ArneGarvan...@discussions.microsoft.com> wrote:
[quoted text clipped - 34 lines]
>
> HTH
slam radio - 21 Nov 2007 19:56 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.