Hola amigos, pues esto ¿como ustedes interceptan
las excepciones en una aplicacion web ASPX .net 2005. por ejemplo el
codigo siguiente es un procedimiento que utilizo para insertar registros
utilizando detailview ¿como controlar aca las excepciones que me puede dar un
insert?. ¿cual es la mejor practica para esto de las excepciones?. gracias nos
leemos
Esto del try no me esta funcionando para coger el
error. ¿alguna sugerencia?.gracias nos leemos
protected void
DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{ e.Values.Clear(); try{ this.SqlDataSource1.InsertParameters["id_base"].DefaultValue = "0"; this.SqlDataSource1.InsertParameters["nombre_base"].DefaultValue = ((TextBox)this.DetailsView1.FindControl("nombre_base")).Text.Trim().ToUpper(); this.SqlDataSource1.InsertParameters["no_base"].DefaultValue = ((TextBox)this.DetailsView1.FindControl("no_base")).Text.Trim().ToUpper(); this.SqlDataSource1.InsertParameters["direccion"].DefaultValue = ((TextBox)this.DetailsView1.FindControl("direccion")).Text.Trim().ToUpper(); this.SqlDataSource1.InsertParameters["municipio"].DefaultValue = ((Controles_Municipios)this.DetailsView1.FindControl("municipios1")).Id_municipio; this.SqlDataSource1.InsertParameters["fax"].DefaultValue = ((TextBox)this.DetailsView1.FindControl("fax")).Text.Trim().ToUpper(); this.SqlDataSource1.InsertParameters["e_mail"].DefaultValue = ((TextBox)this.DetailsView1.FindControl("e_mail")).Text.Trim().ToUpper(); this.SqlDataSource1.InsertParameters["empresa"].DefaultValue = ((DropDownList)this.DetailsView1.FindControl("empresa")).SelectedValue; this.SqlDataSource1.InsertParameters["operacion"].DefaultValue = "0"; this.SqlDataSource1.InsertParameters["id_usuario"].DefaultValue = this.Master.Id_Usuario.ToString(); this.SqlDataSource1.InsertParameters["PK_New"].DefaultValue = "0"; //this.SqlDataSource1.Insert();} catch (Exception ex){ e.Cancel = true;Master.Muestra_mensaje_alerta( " No es posible insertar el Registro, hay un error");} |