



Throw new BusinessRuleException("Duplicate Product") If (ex.GetType().Name = "UpdateException") ProductsBL.CS public void Insert_Product(Product product) (()e.InputParameters).Product.product_name = txtProductName.Text TextBox txtProductName = (TextBox)().FindControl("txtProductName") Product.CS class (Object Data Source Insert command) protected void ODSProducts_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
Insert using objectdatasource with duplicacy check code#
In the Product.cs code behind class I have a function for Inserting Products where I am passing the product Name (see below), this function has a try catch bloeck.should I be throwing the exception here? I thought it would be right to throw the BusinessRulException in the Business Layer. Product BL function Insert_Product is being called from my ObjectDataSource as the Insert function. The Object Data Source TypeName is tied to the Business layer ProductBL I have posted the Insert function in my BL class below, if anyone has an idea what might be causing the Jscript error, please let me know, thanks!! Instead of the Jquery popup that I am expecting with the message "Duplicate Product" Does anyone know what I am doing wrong? does the exception need to behandled in my DAL? but I dont think i should throw BusinessRuleExceptions from somewhere besides the BLL. "Microsoft JScript runtime error: : Exception has been thrown by the target of an invocation." I am trying to catch the exception in my business layer and it seems to run through the catch block fine but I get an error from the Telerik RadScriptManager I have a table with a constraint which throws an exception if a product with a duplicate name is tried as an insert. I am using Entity Framework and Telerik RadGrid.
