FormView Error Handling

  • Thread starter Thread starter Howard
  • Start date Start date
H

Howard

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
 
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?
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top