473,383 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

help needed on ObjectDataSource control

HI,

How to catch custom exception using ObjectDataSource Control.
I am calling Business Layer method through ObjectDataSource control, when
Business layer method throws exception which will be wrapped to custom
exception and thrown. I want to capture the custom exception in UI Layer.

e.g.,
UI Layer Code:
protected void Page_Load(object sender, EventArgs e)
{
try
{
ObjectDataSource1.SelectMethod = "GetAllRoles";

ObjectDataSource1.TypeName =
"Shell.BizTalk.Services.BizDashboard.BusinessLayer .RoleBL";
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
}
catch (BizDashboardException objBizDashboardException) // want to capture Here
{
string s1 = objBizDashboardException.errorNo;
BizDashboardException.publish(objBizDashboardExcep tion);
}
catch (Exception ex)
{
string s = ex.InnerException.Message; // Always capture this exception
}
}

Business Layer Code:
public static roleData GetAllRoles()
{
roleData objRoleData = null;
try
{
int x = objRoleData.Tables[0].Rows.Count;
}

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardException("BSC-001", objException,
objException.Message, "RoleBL-GetAllRoles", Severity.Warning);
}
return objRoleData;
}
--
Manjunath T.
Oct 5 '06 #1
2 2957
Try handling the Selected event of your ObjectDataSource:

protected void ObjectData_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
BizDashboardException ex = e.Exception as BizDashboardException;
if (null != ex)
{
BizDashboardException.publish(ex);
e.ExceptionHandled = true;
}
}

Also, unless you have a _really_ good reason, don't ever do

try
{
...
}
catch(System.Exception ex)
{
DoAbsolutelyNothingWithException(ex);
}

or you won't find out that your app is broken until it's too late.
Manjunath wrote:
HI,

How to catch custom exception using ObjectDataSource Control.
I am calling Business Layer method through ObjectDataSource control, when
Business layer method throws exception which will be wrapped to custom
exception and thrown. I want to capture the custom exception in UI Layer.

e.g.,
UI Layer Code:
protected void Page_Load(object sender, EventArgs e)
{
try
{
ObjectDataSource1.SelectMethod = "GetAllRoles";

ObjectDataSource1.TypeName =
"Shell.BizTalk.Services.BizDashboard.BusinessLayer .RoleBL";
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
}
catch (BizDashboardException objBizDashboardException) // want to capture Here
{
string s1 = objBizDashboardException.errorNo;
BizDashboardException.publish(objBizDashboardExcep tion);
}
catch (Exception ex)
{
string s = ex.InnerException.Message; // Always capture this exception
}
}

Business Layer Code:
public static roleData GetAllRoles()
{
roleData objRoleData = null;
try
{
int x = objRoleData.Tables[0].Rows.Count;
}

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardException("BSC-001", objException,
objException.Message, "RoleBL-GetAllRoles", Severity.Warning);
}
return objRoleData;
}
--
Manjunath T.
Oct 5 '06 #2
HI Flinky Wisty Pomm,

I tried the solution which u provided which is working fine, there is
small changes in the code as below

BizDashboardException ex = e.Exception.InnerException as
BizDashboardException;

if (null != ex)
{
BizDashboardException.publish(ex);
e.ExceptionHandled = true;
}

--
Thanks & Regards,
Manjunath T.
"Flinky Wisty Pomm" wrote:
Try handling the Selected event of your ObjectDataSource:

protected void ObjectData_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
BizDashboardException ex = e.Exception as BizDashboardException;
if (null != ex)
{
BizDashboardException.publish(ex);
e.ExceptionHandled = true;
}
}

Also, unless you have a _really_ good reason, don't ever do

try
{
...
}
catch(System.Exception ex)
{
DoAbsolutelyNothingWithException(ex);
}

or you won't find out that your app is broken until it's too late.
Manjunath wrote:
HI,

How to catch custom exception using ObjectDataSource Control.
I am calling Business Layer method through ObjectDataSource control, when
Business layer method throws exception which will be wrapped to custom
exception and thrown. I want to capture the custom exception in UI Layer.

e.g.,
UI Layer Code:
protected void Page_Load(object sender, EventArgs e)
{
try
{
ObjectDataSource1.SelectMethod = "GetAllRoles";

ObjectDataSource1.TypeName =
"Shell.BizTalk.Services.BizDashboard.BusinessLayer .RoleBL";
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
}
catch (BizDashboardException objBizDashboardException) // want to capture Here
{
string s1 = objBizDashboardException.errorNo;
BizDashboardException.publish(objBizDashboardExcep tion);
}
catch (Exception ex)
{
string s = ex.InnerException.Message; // Always capture this exception
}
}

Business Layer Code:
public static roleData GetAllRoles()
{
roleData objRoleData = null;
try
{
int x = objRoleData.Tables[0].Rows.Count;
}

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardException("BSC-001", objException,
objException.Message, "RoleBL-GetAllRoles", Severity.Warning);
}
return objRoleData;
}
--
Manjunath T.

Oct 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
2
by: planetthoughtful | last post by:
Hi All, I have an ASP.NET page that displays a GridView control based on an ObjectDataSource control. I'm wondering if it's possible to base the ObjectDataSource in question on a parameter...
10
by: J055 | last post by:
Hi I've been trying out SqlCacheDependency using the ObjectDataSource and SQL Server 2005. It all works quite well with the minimum of configuration, e.g. <asp:ObjectDataSource...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
0
by: sugarnet | last post by:
Hi, I have a detailsview that contains templated fields. In the Edit/Insert mode, I would like to populate my DropDown from an ObjectDataSource. The data I need comes from a webservice that I'm...
4
by: Jonathan Wood | last post by:
Greetings, I have a GridView control. For a couple of reasons, I ended up with a TemplateField to contain my Edit and Delete links, something like this: <asp:TemplateField ShowHeader="False">...
0
by: nzkks | last post by:
Hi, I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Objectdatasource using DAL & BLL classes My objectdatasource can produce below output by CategoryID parameter:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.