Web Form Data Field Validation Problem

Web Form Data Field Validation Problem

Old forum URL: forums.lhotka.net/forums/t/2599.aspx


MrCouncilMan posted on Wednesday, March 28, 2007

Hi,

Hoping for some CSLA/Web Form help.  I have a FormView object and a CSLADataSource and I'm not sure if Im just going about it the wrong way.

Problem is when a user enters say an alpha-numeric combination for a field thats meant to contain a decimal its falling over due to type differences when set at Csla.Data.Mapper.Map method in cslaDataSource_InsertObject event is setting the object property for that particular field.  IE:

protected void cslaDataSource_InsertObject(object sender, Csla.Web.InsertObjectArgs e)
 {
  TrafficData obj = TrafficData.NewTrafficData();

  obj.UserName = HttpContext.Current.User.Identity.Name.ToString();

  Csla.Data.DataMapper.Map(e.Values, obj, true, "Id", "DateAdded", "DisplayDate", "StreetName", "SuburbName");
  bool test = obj.IsValid;
  e.RowsAffected = SaveProject(obj, "Inserted Successfully!");
  
 }

I guess the question is where should this invalid data be getting evaluated?  In the object validation or before the fields are mapped?

Copyright (c) Marimer LLC