Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2007, 05:53 PM
Registered User
 
Join Date: Mar 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add/Edit Flow question

My question should be fairly simple I believe but just wanted a few opinions or how you managed the flow.

When you update an item from an add/edit page and click update or even cancel for that matter the automated routines bring you back to a new item entry screen. To me it would make more sense to go back to the listing screen where I selected the item to be edited in the first place.

My questions are:
Is the a parameter or redirect I can insert which still allows the update to occur and return me to my list page?

Does anybody else see this as an issue?

Thanks,
J
 
Old October 24th, 2007, 07:13 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

are you referring some detailsView on TBH ?

 
Old October 25th, 2007, 09:49 AM
Registered User
 
Join Date: Mar 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am referring to the admin of like products or articles. You select a product to edit. You change the price or some other field and click update. The next screen is to enter a new item into the product list. It just doesn't seem to me to be a normal flow. I would like to be returned to the list or even a confirmation that the update was successful but I don't think after an update the next logical place to go would be to add a new item.

Even more strange is the when clicking Cancel it returns me to a new item entry screen instead of where we came from.

Thanks,
J
 
Old October 25th, 2007, 10:54 AM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ummmmm I see!

I gave it a look...

Add this to your addeditarticle code behind:
Code:
        Protected Sub objCurrArticle_Inserted(ByVal sender As Object, _ 
                ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) _ 
                Handles objCurrArticle.Inserted
            Response.Redirect("ManageArticles.aspx")
        End Sub


You can do by your own the same on product page.
Find the objectdatasource that do the "product insert" and make a function like the one that I gave you for articles!

p.s. This only work for new articles inserted. If you want the same for article updated use the same code with the difference = ...objCurrArticle_Updated...

feel free to post some doubt if you have some!
Max
 
Old October 26th, 2007, 05:54 PM
Registered User
 
Join Date: Mar 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maxxim

Thank you many times over, you are good.

It was not exactly the answer I looking for as I code in C# but it sent me down the right path and it is flowing as I like.

I will post my final code changes for reference. As you can see I am not using Articles or Products but Parts Maintenance is actually part of my application.

So in my PartsAddEdit.aspx I modified the following line of code by adding the highlighted.

   <asp:DetailsView ID="dvwPart" runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
      AutoGenerateInsertButton="True" AutoGenerateRows="False" DataKeyNames="PartID" DataSourceID="objCurrPart"
      DefaultMode="Insert" HeaderText="Part Details" OnItemCreated="dvwPart_ItemCreated" OnItemUpdated="dvwPart_OnItemUpdated"
      OnItemInserted="dvwPart_OnItemInserted" OnDataBound="dvwPart_DataBound" OnModeChanged="dvwPart_ModeChanged">

And in my PartsAddEdit.aspx.cs I added the following lines of code.
        protected void dvwPart_OnItemUpdated(object sender, EventArgs e)
        {
            Response.Redirect("ManageParts.aspx");
        }

        protected void dvwPart_OnItemInserted(object sender, EventArgs e)
        {
            Response.Redirect("ManageParts.aspx");
        }


Thanks,
J




 
Old October 26th, 2007, 06:35 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm glad you make it!

You don't need to add the green lines to your detailsView IF you add the "Handles xxxxx.Inserted" on your code behind.

But this might confuse you...
Your version work too, but in this way you need to change the aspx and the code behind.
I don't know if you know that:
In Visual Studio open your cs file.
You have two dropdown lists on the top. General at left and declarations on right.
If you select you datasource/details view from you "general" dropdown, then select the event that you want (Inserted... Updated... etc)
When you do that, the cs file generate the "handles" for your control!
I mean: Asp.Net will be watching for this event!

But if this strange fro you, use your way, because it works too!

Thanks for post the C version!









Similar Threads
Thread Thread Starter Forum Replies Last Post
Tabs + Subforms + Add/Edit = No Go hkmulligan Access 5 August 10th, 2007 06:54 AM
Edit/Add/Delete within a DataGrid ozzy VB.NET 2002/2003 Basics 5 January 23rd, 2005 01:17 AM
how to know who edit or add records? drachx General .NET 1 October 13th, 2004 05:36 AM
how to know who edit add records? drachx SQL Server 2000 9 October 13th, 2004 04:28 AM
Given the datalist. How do I add edit mode? macupryk General .NET 0 October 8th, 2004 12:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.