473,395 Members | 2,436 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,395 software developers and data experts.

FormView Error Handling

I use FormView and ObjectDataSource to take user inputs
in adduser.aspx page i have
<asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage"
InsertMethod="addstudent">

and in my app_code foler i have a method that looks like
public static void addstudent(...)
{
try
{
//do sql queries
catch(Exception e)
{
//return error message
}
}

this works fine when the inputs get inserted to the database, i call the
event OnItemInserted
My questions is how would i get the error message back to the aspx page?

Thanks,
Howard
Jun 7 '06 #1
3 3663
Handle the ObjectDataSource's Inserted event and check the EventArgs Exception
property. If this is non-null then you can "handle" the exception by setting
the EventArgs' ExcaptionHandled = true;

-Brock
http://staff.develop.com/ballen

I use FormView and ObjectDataSource to take user inputs
in adduser.aspx page i have
<asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage"
InsertMethod="addstudent">
and in my app_code foler i have a method that looks like
public static void addstudent(...)
{
try
{
//do sql queries
catch(Exception e)
{
//return error message
}
}
this works fine when the inputs get inserted to the database, i call
the
event OnItemInserted
My questions is how would i get the error message back to the aspx
page?
Thanks,
Howard

Jun 7 '06 #2
I still can't get it to work, tried everything

protected void ObjectDataSource1_Inserted(object sender,
ObjectDataSourceStatusEventArgs e)
{
if (e.Exception != null)
label1.message = "ERROR!";
}
In the business object i put
try
{
throw new Exception("test");
catch (Exception e)
{
}
e.Exception is always null, what did I do wrong. How come the exception is
not being passed to the Inserted event?
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8************************@msnews.microsoft.c om...
Handle the ObjectDataSource's Inserted event and check the EventArgs
Exception property. If this is non-null then you can "handle" the
exception by setting the EventArgs' ExcaptionHandled = true;

-Brock
http://staff.develop.com/ballen

I use FormView and ObjectDataSource to take user inputs
in adduser.aspx page i have
<asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage"
InsertMethod="addstudent">
and in my app_code foler i have a method that looks like
public static void addstudent(...)
{
try
{
//do sql queries
catch(Exception e)
{
//return error message
}
}
this works fine when the inputs get inserted to the database, i call
the
event OnItemInserted
My questions is how would i get the error message back to the aspx
page?
Thanks,
Howard


Jun 7 '06 #3
I still can't get it to work, tried everything

protected void ObjectDataSource1_Inserted(object sender,
ObjectDataSourceStatusEventArgs e)
{
if (e.Exception != null)
label1.message = "ERROR!";
}
In the business object i put
try
{
throw new Exception("test");
catch (Exception e)
{
}
e.Exception is always null, what did I do wrong. How come the exception is
not being passed to the Inserted event?
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8************************@msnews.microsoft.c om...
Handle the ObjectDataSource's Inserted event and check the EventArgs
Exception property. If this is non-null then you can "handle" the
exception by setting the EventArgs' ExcaptionHandled = true;

-Brock
http://staff.develop.com/ballen

I use FormView and ObjectDataSource to take user inputs
in adduser.aspx page i have
<asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage"
InsertMethod="addstudent">
and in my app_code foler i have a method that looks like
public static void addstudent(...)
{
try
{
//do sql queries
catch(Exception e)
{
//return error message
}
}
this works fine when the inputs get inserted to the database, i call
the
event OnItemInserted
My questions is how would i get the error message back to the aspx
page?
Thanks,
Howard



Jun 7 '06 #4

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

Similar topics

8
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
1
by: yuchang | last post by:
Hi, Using the FormView control is very efficient. But I want to do some action,like showing a success message or redirect to another page, after inserting, updating and deleting. How do I get...
4
by: Rob | last post by:
Hey all, So.. a simple FormView/SqlDataSource to handle inserting records into a table. The table has a primary key that the user enters (eg DiscountCode). If the user enters a duplicate the...
1
by: | last post by:
Is there a way to handle when you're on insert mode on a formview and the record you're about to save to the database already exist and insted you rather update instead of inserting and getting an...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
1
by: Larry Bud | last post by:
Got a Formview, and on the datasource "inserted" call, I check to see if there was a SQL exception (such as a unique key failure). I then handle the exception, displaying an error in a label. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.