asp.net ObjectDataSource error handling - asp.net

I have objectdatasource and I am trying to find a way to capture the error that is thrown by the SELECT method.
anyone idea how it can be done?
Page level error handling is preferred, not capturing error at the application_error in global.asax
thanks,

Like this:
protected void Page_Load(object sender, EventArgs e)
{
ds.Selected += new ObjectDataSourceStatusEventHandler(ds_Selected);
}
void ds_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.Exception != null)
{
}
}

Related

Pass value from one xaml page to another xaml page in silverlight

Hello I am very new to Silverlight and I want to pass value from one Xaml page to another Xaml page in Silverlight. I got some solution for that as
protected void btn_click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page1.xaml?key1"=txtname.Text, UriKind.Relative));
}
but I am finding an error in it as
An object reference is required for the non-static field, method, property System.Windows.Navigation.NavigationService.Navigate(System.Uri)'
Syntax issue. unless that is a typo
protected void btn_click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page1.xaml?key1"=txtname.Text, UriKind.Relative));
}
should change to...
protected void btn_click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page1.xaml?key1="+txtname.Text, UriKind.Relative));
}
Note the change from
"/Page1.xaml?key1"=txtname.Text
to
"/Page1.xaml?key1="+txtname.Text

Create specific LoginError asp.net

I'm using the LoginPage by .net 4.5.
When the fields are empty I get an error in red which say I can't connect.
What I want to do, is when I enter username and passwords, I try to log into DB, and if I get false, I want a custom error which says I can't log into DB.
Here is the code:
protected void LoginButton_Click(object sender, EventArgs e)
{
if (!DBHandle.DBConnect(UserLogin.UserName, UserLogin.Password))
{
}
}
protected void UserName_TextChanged(object sender, EventArgs e)
{
}
protected void UserLogin_LoginError(object sender, EventArgs e)
{
UserLogin.FailureText = "asdad";
}
What I have to put in the condition, that cause to get to LoginError?
Thanks!

validation conflicts with routing

I have a trouble with asp.net validations. At first my validation worked successfully. But when I began to routing, my clientside validations didn't work. There is successful and unsuccessfull codes:
Unsuccessful example :
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add("Pages", new Route("{PageName}/", new PageRouteHandler("~/Page.aspx")));
}
Successful example :
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add("Pages", new Route("PageName/", new PageRouteHandler("~/Page.aspx")));
}
How can I overcome this problem?

How to get event in another control event?

In my application, i am trying to get button_click event in another button click event, but it is not working.
My code is,
protected void btn1_Click(object sender, EventArgs e)
{
Response.Write("hi.....");
}
protected void btn2_Click(object sender, EventArgs e)
{
btn1.Click += new EventHandler(this.btn1_Click);
}
What is wrong with this?
I suppose you want to call the code of btn1_click event.
If this is the case, you simple call it as a method in your btn2_Click.
protected void btn2_Click(object sender, EventArgs e)
{
btn1_Click (sender, e);
}

I got the problem in Crystal Report- Error Messsage:Load report failed

I got the problem in Crystal Report- Error Messsage:Load report failed.
how to solve this issue??.
You can call show data on report in DataBinding and Navigate methods.
protected void CrystalReportViewer1_DataBinding(object sender, EventArgs e)
{
this.ShowReportData();
}
protected void CrystalReportViewer1_Navigate(object source, CrystalDecisions.Web.NavigateEventArgs e)
{
this.ShowReportData();
}
If your report is running for awhile and then falls over make sure you Dispose it.......
if(myReport != null)
{
myReport .Close();
myReport .Dispose();
}

Resources