473,785 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help needed on ObjectDataSourc e control

HI,

How to catch custom exception using ObjectDataSourc e Control.
I am calling Business Layer method through ObjectDataSourc e 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(objec t sender, EventArgs e)
{
try
{
ObjectDataSourc e1.SelectMethod = "GetAllRole s";

ObjectDataSourc e1.TypeName =
"Shell.BizTalk. Services.BizDas hboard.Business Layer.RoleBL";
GridView1.DataS ourceID = "ObjectDataSour ce1";
GridView1.DataB ind();
}
catch (BizDashboardEx ception objBizDashboard Exception) // want to capture Here
{
string s1 = objBizDashboard Exception.error No;
BizDashboardExc eption.publish( objBizDashboard Exception);
}
catch (Exception ex)
{
string s = ex.InnerExcepti on.Message; // Always capture this exception
}
}

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

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardExc eption("BSC-001", objException,
objException.Me ssage, "RoleBL-GetAllRoles", Severity.Warnin g);
}
return objRoleData;
}
--
Manjunath T.
Oct 5 '06 #1
2 2976
Try handling the Selected event of your ObjectDataSourc e:

protected void ObjectData_Sele cted(object sender,
ObjectDataSourc eStatusEventArg s e)
{
BizDashboardExc eption ex = e.Exception as BizDashboardExc eption;
if (null != ex)
{
BizDashboardExc eption.publish( ex);
e.ExceptionHand led = true;
}
}

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

try
{
...
}
catch(System.Ex ception ex)
{
DoAbsolutelyNot hingWithExcepti on(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 ObjectDataSourc e Control.
I am calling Business Layer method through ObjectDataSourc e 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(objec t sender, EventArgs e)
{
try
{
ObjectDataSourc e1.SelectMethod = "GetAllRole s";

ObjectDataSourc e1.TypeName =
"Shell.BizTalk. Services.BizDas hboard.Business Layer.RoleBL";
GridView1.DataS ourceID = "ObjectDataSour ce1";
GridView1.DataB ind();
}
catch (BizDashboardEx ception objBizDashboard Exception) // want to capture Here
{
string s1 = objBizDashboard Exception.error No;
BizDashboardExc eption.publish( objBizDashboard Exception);
}
catch (Exception ex)
{
string s = ex.InnerExcepti on.Message; // Always capture this exception
}
}

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

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardExc eption("BSC-001", objException,
objException.Me ssage, "RoleBL-GetAllRoles", Severity.Warnin g);
}
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

BizDashboardExc eption ex = e.Exception.Inn erException as
BizDashboardExc eption;

if (null != ex)
{
BizDashboardExc eption.publish( ex);
e.ExceptionHand led = true;
}

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

protected void ObjectData_Sele cted(object sender,
ObjectDataSourc eStatusEventArg s e)
{
BizDashboardExc eption ex = e.Exception as BizDashboardExc eption;
if (null != ex)
{
BizDashboardExc eption.publish( ex);
e.ExceptionHand led = true;
}
}

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

try
{
...
}
catch(System.Ex ception ex)
{
DoAbsolutelyNot hingWithExcepti on(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 ObjectDataSourc e Control.
I am calling Business Layer method through ObjectDataSourc e 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(objec t sender, EventArgs e)
{
try
{
ObjectDataSourc e1.SelectMethod = "GetAllRole s";

ObjectDataSourc e1.TypeName =
"Shell.BizTalk. Services.BizDas hboard.Business Layer.RoleBL";
GridView1.DataS ourceID = "ObjectDataSour ce1";
GridView1.DataB ind();
}
catch (BizDashboardEx ception objBizDashboard Exception) // want to capture Here
{
string s1 = objBizDashboard Exception.error No;
BizDashboardExc eption.publish( objBizDashboard Exception);
}
catch (Exception ex)
{
string s = ex.InnerExcepti on.Message; // Always capture this exception
}
}

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

catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardExc eption("BSC-001", objException,
objException.Me ssage, "RoleBL-GetAllRoles", Severity.Warnin g);
}
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
8706
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 update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
5
1990
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 parameter. When the Update-method is invoked by the ObjectDataSource, the object referenced is not the same object returned by the Select-method, but a new object with only the values from the Edit-template. So basically I get a reference to a useless...
2
6270
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" SelectMethod="GetUsers" TypeName="BizObject"></asp:ObjectDataSource> This works, however I need to explicitly clear/remove the cache when I
2
12802
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 query, with the ability to set the parameter value at run time (in the Page_Load event, perhaps?)? Basically, I'd like to display records in the GridView based on values
10
4581
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 ID="odsAccounts" runat="server" ... EnableCaching="true" SqlCacheDependency="CommandNotification"> .... </asp:ObjectDataSource>
8
18090
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 display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
0
994
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 calling. I wrapped it into an object that have a function (GetAgentList) that return a datatable. I usually have no problem using that with SQLDataSource. May be I'm missing something with ObjectDataSource I get a weird error message (see below)....
4
1809
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"> <EditItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton> &nbsp;<asp:LinkButton ID="LinkButton2" runat="server"
0
1337
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: (stored procedure: GetProductsByCategoryID ) CategoryID | CollectionID | ProductID | CategoryName | CollectionName | ProductName | ProductPhoto 1 1 3 XYZ ABC Prod3 ...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.