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. 2 2977
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.
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
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...
|
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
|
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
|
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>
| |
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.
|
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)....
|
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>
<asp:LinkButton ID="LinkButton2" runat="server"
|
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 ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |