Handling Exceptions ObjectDatasource BLL to the user pagehttp://forums.asp.net/t/1789009.aspx/1?Handling+Exceptions+ObjectDatasource+BLL+to+the+user+pageTue, 10 Apr 2012 00:59:36 -040017890094915439http://forums.asp.net/p/1789009/4915439.aspx/1?Handling+Exceptions+ObjectDatasource+BLL+to+the+user+pageHandling Exceptions ObjectDatasource BLL to the user page <p>I have a problem to send the exceptions from BLL to the user page. when I&nbsp;try to insert data from the Detailsview this messag appear: &quot;NullReferenceException was unhandled by the user code&quot;. How&nbsp;should I&nbsp;relate BLL to the Detailsview (user page)?&nbsp;&nbsp;I attached below the code for the BLL and user page.</p> <p>BLL:</p> <pre class="prettyprint">[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, false)] public void InsertForestPhotos(int PhotoId, byte[] Photo, System.DateTime Date, string FileName) { try { AdapterForestPhoto.InsertForestPhotos(PhotoId, Photo, Date, FileName); } catch (Exception) { }</pre> <p>Detailsview code:</p> <pre class="prettyprint">protected void ForestPhotoDetail_ItemInserted(Object sender, DetailsViewInsertedEventArgs e) { // Use the Exception property to determine whether an exception // occurred during the insert operation. if (e.Exception == null &amp;&amp; e.AffectedRows == 1) { // Use the Values property to get the value entered by // the user for the CompanyName field. String name = e.Values["PhotoID"].ToString(); //ExceptionDetails.Visible = true; // Display a confirmation message. ExceptionDetails.Text = name + " added successfully. "; } else { // Insert the code to handle the exception. ExceptionDetails.Text= e.Exception.Message; //ExceptionDetails.Visible = true; // Use the ExceptionHandled property to indicate that the // exception is already handled. e.ExceptionHandled = true; // When an exception occurs, keep the DetailsView // control in insert mode. e.KeepInInsertMode = true; GridView1.DataBind(); } } </pre> <p></p> <p><br> &nbsp;</p> 2012-04-04T09:20:51-04:004918791http://forums.asp.net/p/1789009/4918791.aspx/1?Re+Handling+Exceptions+ObjectDatasource+BLL+to+the+user+pageRe: Handling Exceptions ObjectDatasource BLL to the user page <p>Hello</p> <p>Consider that your Photo is type of byte[]And it's not a standard typeI suggest you use a FileUpLoader to load the image and then use File.ReadAllBytes to set the property in the DetailsView_ItemUpdating event and do something like this</p> <p>Plz see my sample at CodePlex</p> <p>C# &amp; VB.NET<a href="http://1code.codeplex.com/releases/view/59639#DownloadId=201858" target="_blank">Download</a></p> <p>Reguards</p> 2012-04-06T01:28:25-04:004923703http://forums.asp.net/p/1789009/4923703.aspx/1?Re+Handling+Exceptions+ObjectDatasource+BLL+to+the+user+pageRe: Handling Exceptions ObjectDatasource BLL to the user page <p>Sorry but&nbsp;I can't see the sample at CodePlex.</p> <p>&nbsp;</p> <p>&nbsp;</p> 2012-04-09T20:29:13-04:004923860http://forums.asp.net/p/1789009/4923860.aspx/1?Re+Handling+Exceptions+ObjectDatasource+BLL+to+the+user+pageRe: Handling Exceptions ObjectDatasource BLL to the user page <p></p> <blockquote><span class="icon-blockquote"></span> <h4>azaria</h4> Sorry but&nbsp;I can't see the sample at CodePlex.</blockquote> <p></p> <p>OOpsVery sorry but it seems that my sample at CodePlex has been moved by someone to<a href="http://code.msdn.microsoft.com/Uploadedit-image-in-ASPNET-b96367a9">http://code.msdn.microsoft.com/Uploadedit-image-in-ASPNET-b96367a9</a></p> <p>You can download there</p> <p>Reguards</p> 2012-04-10T00:59:36-04:00