Forms Data Controls :: Formview - How To Link A Custom Error Page
Jan 20, 2010
Being A C++ programmer this is fairly new to me - I am working on a formview and have been facing a problem- The issue is simple - I want to display a success page after I insert a row successfully and a custom error page if the insertion fails (due to datatype or format mismatch with table in database).
To achieve this I am doing as follows -
1. Defining a custom error page in ASP.NET configuration tool (webconfig)
>> This page never works if I enter an incorrect format in formview. It would rather display the ugly page with Server Error information (for example) -
The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
question - Why my default page is not getting displayed? Is it because I am testing from same development machine or is it because the error page doesnt work for "Server Error" pages?
2. In the "iteminserted" event I am redirecting it to Response.Redirect("~/newitemconfirm.aspx")
>> If I do this, irrespective of whether the row insertion was successful or not, this confirmation page always gets displayed! I want it to be displayed only on successful insertion.
View 2 Replies
Similar Messages:
Apr 8, 2010
i have the following scenario: one formview. when in editmode there is a child formview linked to the other by a column value. i need to take the value of one of the values of parent formview controls and set it to a textbox of child formview in insert mode. I wish to know which event should I use in codebehind to bind both controls? (that escenario will have paging and must keep the binding as if it was master detail)
View 9 Replies
Nov 30, 2010
my C# console appliccation code is shown below :-
[Code]....
In my application a mail message send to particular recipeeient with msg body contains a hyper link.. when the recipent click on this link,it will redirect to another form(InternalForm.aspx)... bt when clicking the link error is occured,whuy its happening???? In InternalForm.aspx,page load portion access the link content(badgeno).. page load portion code of InternalForm.aspx is shown below:-
[Code]....
View 7 Replies
Sep 7, 2010
FormView custom data binding problem
View 7 Replies
Jan 19, 2010
I have method that I call which needs to find all the panels in the page but it fails. I have another method that was created by the VS has the traditional paraeters such the object sender, EventArgs e that the similar code works fine but the (simplyfied) code below. It is clear to me that these parameters contain information that makes one method work while the other not, but I don't know why.
The code breaks on the last line of code: _pnlAssetInfo = (Panel.....
[Code]....
View 3 Replies
May 20, 2010
I need to do a custom update for a form view (I think/know), as some of the parameters that are required for updating values should not be updated by the users, such as userid of the person performing the action which is passed back to the database for auditing purposes.
Additionally, there are some fields, such as LastUpdatedBy, LastUpdatedDate that need to be seen, but not edited. The stored procedure on the backend takes care of this, and these are not parameters for the Update method. The FormView by default is trying to pass all these values back to the database.
Lasty, the select query of the object datasource is a stored procedure that performs several joins based on PF/FK relationships to bring back more meaningful information than just a FK, so some columns are just the joined value, and can not be updated directly. Again, formview is trying to pass these parameters
So given that, I have defined the following even handler for a simple form view:
(not sure if this is the way to proceed given the above, but...)
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
ProjectDetailsDataSource.UpdateParameters.Clear();
ProjectDetailsDataSource.UpdateParameters.Add("projectID", ((Guid)e.Keys["ProjectID"]).ToString());
ProjectDetailsDataSource.UpdateParameters.Add("projectName", (string)e.NewValues["ProjectName"]);
ProjectDetailsDataSource.UpdateParameters.Add("description", (string)e.NewValues["Description"]);
ProjectDetailsDataSource.UpdateParameters.Add("projectTypeID", "1");
ProjectDetailsDataSource.UpdateParameters.Add("statusID", "1");
ProjectDetailsDataSource.UpdateParameters.Add("productID", null);
ProjectDetailsDataSource.UpdateParameters.Add("isComplete", ((bool)e.NewValues["IsComplete"]).ToString());
ProjectDetailsDataSource.UpdateParameters.Add("isActive", ((bool)e.NewValues["IsActive"]).ToString());
ProjectDetailsDataSource.UpdateParameters.Add("userid", Membership.GetUser().ProviderUserKey.ToString());
ProjectDetailsDataSource.Update();
FormView1.ChangeMode(FormViewMode.ReadOnly);
e.Cancel = true;
}
My questions are as follows:
1) Is this the right approach?
2) Is so, when I cancel the edit (because I did the update myself), and change mode, the FormView returns to read only mode as inteneded (good so far). However, when I hit F5 (refresh), the ItemUpdating method is called again, and updates the database.
View 4 Replies
Feb 3, 2011
The new values entered by a user are lost when a error occurs.
I tried to solve this by catching the error in the item updated event as per the code below
[Code]....
however the data in the form gets set back to the original values.
It seams as though the object data source is rebinding the form. How can i determine if this is the case? Is there a way to stop the datasource from rebining?
View 6 Replies
Jun 29, 2010
I have a formview and within it I have a dropdown list which brings back a list of value from my database,
View 2 Replies
May 7, 2015
I want put custom error page in my website so I wrote below code in web.config
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="error-404.aspx" responseMode="ExecuteURL" />
</httpErrors>
is it correct?
or I should put other code?
View 1 Replies
Aug 9, 2010
I'm trying to create a Formview in ASP.net 3.5. The underlying SQL Server table does not have an identity field based Primary Key. The primary key is a 4 character user entered field. I have created the form and all looks good but I get the following error message when I try to insert a record
Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation.
I thought ViewState was supposed to resolve the issue. I have viewstate enabled on the page and the formview but that doesn't seem to make a difference.
How can I create a form view with a user-entered text field as the primary key and get the b.... thing to work?
View 1 Replies
May 4, 2010
I have a FormView with an EditTemplate.And the EditTemplate contains an ascx control:
<asp:FormView
ID="fvTicketUpdate"
runat="server"
[code]...
The contents of the ascx control has TextBox and DropDownList controls binding to the results of the FormView's ObjectDataSource through Text='<%# Eval("field1") %>'and SelectedValue='<%# Eval("field2") %>'.This works fine and I have been building all of my front end pieces like this as <asp:Panels> rendering as FieldSets that go 100% across the screen.And we call these areas "strips" accross the screen.But now I've run into a problem.One TextBox and one DropDown bind fine to a Ticket Object.But the DropDownList that works has its <asp:ListItems> hardcoded before hand.Now I have DropDownList that gets populated through a WebService in the ascx's
code behind like this:
public partial class UserControls_FormControls_PntipUpdtFaaInfo :
System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
[code]...
The Problem I think is the FormView is trying to do its Bind to the objectDataSource before its child ascx control is loaded in the Edit Template.And I am getting this error:
Databinding methods such as Eval(),XPath(),and Bind() can only be used in the context of a databound control.Meaning that the control must already be databound to bind the selectedValue to a Property of the TicketObject.Is there an easy way to force the order of loading to make the PntipUpdtFaaInfo control load and have its Page_Load execute and bind ddlEquip before the FormView does its first dataBind and executing its Evals?Otherwise I have to take out the eval on the ddlEquip SelectedValue attribute and go to the Parent Page and hack and force everything to happen when it needs to.This layout has worked out well for me.All of the ascx area strips across the screen share the same Validation Summary for example.It allows me to think about one section at a time and the Properties to the Business Obect and CRUD methods as I go.But this is a big brick wall I've hit.
View 1 Replies
Jan 2, 2011
I am currently able to pass parameter from 1 page to another but I am unable to retrieve it.
<asp:HyperLinkField DataNavigateUrlFields="ID"
View 5 Replies
Sep 22, 2010
I have a master page with a textbox that I want to use for a search, and display the results on the content page.
I've dragged in the datasource to the content page, and configured the formview to use that datasource... almost.
The issue I'm having is that on the last step of the configure datasource wizard where you select the parameters, I want to select the master page textbox control for the search parameter... but of course it's not available in the list. The list only allows me to choose controls from the content page.
How do I set this master page search box as the parameter for my datasource?
View 4 Replies
Feb 7, 2011
I was wondering if someone could point me in the right direction:
How do I generate a custom error page with the error message and get it to mail me that error message?
Is there a good tutorial out there that someone could point me 2.
View 4 Replies
Feb 13, 2011
I am using a formview on main web page and the Item template displays my data correctly but I get and error when I try and link to the edit or insert templates.This happens on our remote tesing server only.On my local machine running the page on the local server in VS 2010 everything works fine.But then doesn't it always work on your local machine.I might also mention that I am compiling for asp.net 4.0.
Here is the stack trace :
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'MYCORPABIGWEB01$'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
[code]...
View 1 Replies
Jul 19, 2010
I am getting error below when I click on edit link on my grid view.
Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'
here is my aspx:
[Code]....
and here is my .cs:
[Code]....
View 19 Replies
Aug 13, 2010
I'm trying to get a link to load a new page that passes a value to the new page. To my dismay I've found out (or im doing it wrong) that this doesn't work in the repeater.
[Code]....
How would i get something like that to work in my repeater so it can show a new News page with more information on it.
View 3 Replies
Feb 9, 2011
I'd like to implement a custom paging template for my formview that displays numeric paging as well as next/previous buttons. The pre-defined templates only appear to have numeric first last as an option. Can anyone recommend a good article that covers this?
View 2 Replies
Mar 7, 2011
I'm having a wicked time trying to redirect the different error scenarios to a custom error page. Basically, I have put some code in Application_Error in global.asax, and done the necessary web.config settings to use Custom Errors.
In global.asax on Application_Error, I stored the Server.GetLastError in Session. The reason I have to store it in Session is because (as far as I know) you lose the exception when using "ResponseRedirect". And the reason I have to use ResponseRedirect is because I am using an UpdatePanel with AJAX calls, and any exception during the AJAX call shows up as a JavaScript error, and doesn't get handled using the custom error page (see this post).
void Application_Error(object sender, EventArgs e){ ////must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { Session["LastException"] = Server.GetLastError(); } else { // (I think this happens when there are compile-time errors) Server.Transfer("~/Oops.aspx"); }}void Session_Start(object sender, EventArgs e){ //must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { //initialize the session (http://forums.asp.net/t/1405077.aspx) Session["LastException"] = ""; }}
View 3 Replies
Jul 2, 2012
I am trying to handle the unhandled exceptions in my project.I tried with this following code in my web.config filebut it is not at all redirecting to an error page which i have created instead of that it is throwing an exception in my code itselef. How to print the error description over therein my custom error page.
---------------------------------------------------------------------------------------------------
<sys.web>......<customErrors mode="On" defaultRedirect="~/Error.aspx"></customErrors>...</sys.web>
---------------------------------------------------------------------------------------------------
And even i tried in Global.asax page in Application_Error() method like below
 Exception ex = Server.GetLastError();Response.Redirect("~/Error.aspx?errmsg="+ex.message);Server.ClearError();
And in my Error.aspx.cs page i have placed a label and i have written code like this
protected void Page_Load(object sender, EventArgs e)Â Â Â Â Â Â Â {
        Label1.Text=Request["errmsg"];
     }
But it is not getting redirected my error page and not displaying anything on it.
View 1 Replies
Jan 27, 2010
In my webpage I have a Formview bounded by sqldatasource. I can perfectly Update data from it. In the same page I have a gridview bounded by some other sqldatasource. I have to give user new record option from gridview.
I know that there is no default property to insert new record with the help of gridview until we provide some other way by coding but I don't want to do that.
Therefore I have taken a textbox with the validation field and a button outside the gridview to insert new record into gridview and refresh it.
I don't want to allow user to add empty text using textbox thatswhy I have validated that textbox.
Problem:
If user has the scenario to update only the Formview then he cannot because there is a validation there with the textbox.
If I remove the validation then user is able to update FormView perfectly but may add empty text from the textbox.
if the user allowed to update FormView and to add data with the help of textbox and gridview get refresh. If user can do only one task also either to update FormView or to add data from textbox to refresh gridview.
The task is most important for me and I have only 12 hours to complete this task or you can say the time limit is going to expire.
View 3 Replies
May 23, 2010
I have a gridview with 2 chosen colums, and i want one of them to be a link. When i click the link, a formView with all colums of that record will appear in the same page.
I have menage to do this but then i had the formView in another aspx page. Now i want the formView to be visible in the same page as the gridView.
How can i menage that? Do i need a Panel or something?
View 2 Replies
Jan 9, 2011
I have 4 buttons and 1 FormView.
The FormView has AllowPaging = true.
When you click on a button SQLDataSource1 is bind to the FormView.
So you always have 4 pages.
The data in the FormView has an ID.
When you click Button1 you know you want to see the data with ID=4.
When you click Button2 you know you want to see the data with ID=1.
When you click Button3 you know you want to see the data with ID=2.
When you click Button4 you know you want to see the data with ID=3.
What I want is: when you click on a Button you get the page in the FormView
that corresponds with the ID of the data.
So page 1 isn't ID=1!
What do I have to program to get this working?
View 3 Replies
Oct 28, 2010
I am showing Custom Error in my page.if somehting happend wrong. but if the same error occured in my subview master page I am not able to show the Custom error page on Entire page its showing me that Error page under subview master page.I am attching the Screen shot.Can any body help me out how to show the Error page on entire page if something happend in any where submaster or other page.Here is the code that I am using in web config file to show custom Error page..
[CODE]...
Here I know the issue what's going on.This issue is occurring because i am using AJAX to partially load the contents of the tabs after the initial page load so the error is occurring AFTER my master page has been loaded.What I need to do is provide a javascript function to handle the error after the ajax call has returned and redirect to the error page.How to write this Javascript and where Do I need to write this?
View 4 Replies
Sep 10, 2010
I would like to ask if it is possible to access data on a master FormView from a nested detail FormView.
I have a main form (master) with several tabs (detail) and would like to display a label with text from main form that is hidden by the tab at the moment of editting. My asp page looks like this.
[Code]....
Is it possible to get the value of the label CompanyTextLabel from CompanyTextBox using just ASP.NET expressions or something similar without writing c# code in .cs file?
View 4 Replies