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

July 3rd, 2009, 05:42 AM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.}
|

July 3rd, 2009, 06:16 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 69
Thanks: 16
Thanked 1 Time in 1 Post
|
|
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.
|
|
The Following User Says Thank You to yevi For This Useful Post:
|
|

July 5th, 2009, 04:20 AM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |