p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 3rd, 2009, 05:42 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Unhappy How to get value form BLL to Form View

Could you please help me, I would like to know about developing program by MVC.
(User Interface, Business Logic Layer, Data Access Layer)
According to Data from Form View can collect into database,
so I create ID for use in next screen.
This process should operate before write in database by Business Logic.
However, it was not work because data did not send to User Interface using FormView.
Acutally, I have InsertSomething method for collect data to database responsible for keep log and create new ID.
This method is in MB.SomeNameSpace.BLL.SomeClass

My example code :

Code (ASP)
HTML Code:
01.<%
02....
03.<asp:FormView ID="FormView1" runat="server" DataKeyNames="ProjectID" DataSourceID="ODS1"
04.        DefaultMode="Insert" OnItemInserted="FormView1_ItemInserted">
05. 
06. ... Other Template ...
07. 
08.</asp:FormView>
09.<asp:objectDataSource ID="ODS1" runat="server" InsertMethod="InsertSomething" SelectMethod="GetSomething"
10. 
11.TypeName="MB.SomeNameSpace.BLL.SomeClass.SomeInsertMethod">
12.<SelectParameters>
13.     <asp:QueryStringParameter DefaultValue="0" Name="FieldID" Type="String" />
14.</SelectParameters>
15.<InsertParameters>
16.       <asp:Parameter Name="FieldID" Type="String" Direction="ReturnValue" />
17.       <asp:Parameter .....>
18.</InsertParameters>
19.%>
Code behind (C#)
Code:
01.protected void Page_Load(object sender, EventArgs e)
02.{
03.}
04.protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
05.{
06. FormView1.ChangeMode(FormViewMode.ReadOnly);      // it not work
07.FormView1.DataBind();  // Still not work too
08.     
09.      // How to get ID when item inserted
10.}
Business Logic Layer Code (C#)
Code:
01.namespace MB.SomeNameSpace.BLL
02.{
03. public class SomeClass : SomeBaseClass
04. {
05.    ....
06. }
07. public static String InsertSomething(SomeParam, ..., ...)
08. {
09.    NewID = SiteProvider.SomeClass.MakeNewID(bySomeCode);    
10.    SomeDetails record = new SomeDetails(SomeParam, ..., ...);  
11.    bool ret = SiteProvider.SomeClass.InsertProject(record);    
12.   if(ret) {
13.        DoMyBussinessSomething();
14.      // Here, NewID Has value
15.    return NewID;
16.  } else {
17.     String.Empty;
18.  }
19.    }
20.}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 3rd, 2009, 06:16 PM
Authorized User
Points: 281, Level: 5
Points: 281, Level: 5 Points: 281, Level: 5 Points: 281, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 69
Thanks: 16
Thanked 1 Time in 1 Post
Default

Hi,
I couldn't understand from your post what exactly you are trying to do.

But I guess you are trying to get back the generated value that is returned by the Stored Procedure?
If I take BeerHouse as an example, you want to get the ID of the Inserted Comment (article, category and etc)?

If this is so, one way to do it is:
First to remove
<asp:Parameter Name="FieldID" Type="String" Direction="ReturnValue" />
from the objectatasource , then simply add to "Inserted" event to the objectatasource and from there get the returned value:

int x = (int)e.ReturnValue;

(where e is ObjectDataSourceStatusEventArgs )

If this is not what you want please tell.

Last edited by yevi : July 3rd, 2009 at 06:18 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to yevi For This Useful Post:
nitis (July 5th, 2009)
  #3 (permalink)  
Old July 5th, 2009, 04:20 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you so much for your suggestion.

Fix in ASP
<asp:objectDataSource ID="ODS1" runat="server" InsertMethod="InsertSomething" SelectMethod="GetSomething"
OnItemInserted="ODS1_ItemInserted">

Fix in Code Behide
protectedvoid ODS1_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.ReturnValue != null)
{
ViewState[
"ID"] = e.ReturnValue.ToString();
...
...
}
}

Last edited by nitis : July 5th, 2009 at 04:36 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to view picture by using form view? mysecondlove ASP.NET 2.0 Basics 1 April 8th, 2008 08:17 AM
Form View in User Control shoakat ASP.NET 2.0 Professional 0 June 20th, 2007 08:29 AM
View an ado recordset in a form feets Access VBA 5 June 20th, 2007 07:19 AM
Form View Controls Unaccessable Mehranian ASP.NET 2.0 Professional 1 May 21st, 2006 05:02 PM
Resizing of form view - problem lmadhavi Visual C++ 2 October 1st, 2004 07:18 AM



All times are GMT -4. The time now is 06:49 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc