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