ASP.NET databinding questionASP.NET databinding question
Old forum URL: forums.lhotka.net/forums/t/7937.aspx
forrest posted on Monday, November 02, 2009
In projectEdit.aspx,the detailsview has
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />,and then following methods
protected void ProjectDataSource_InsertObject(
object sender, Csla.Web.InsertObjectArgs e)
{
Project obj = GetProject();
Csla.Data.DataMapper.Map(e.Values, obj, "Id");
e.RowsAffected = SaveProject(obj);
}
protected void ProjectDataSource_UpdateObject(object sender, Csla.Web.UpdateObjectArgs e)
{
Project obj = GetProject();
Csla.Data.DataMapper.Map(e.Values, obj);
e.RowsAffected = SaveProject(obj);
}
can be called automatic.
But in my code,I do not want to use these commandfield button in detailsview,because there is other buttons like 'AuditOrder/SendOrder/PrintOrder/ApplyInvoice' in this page.
so I want to place all buttons together. so there is a button 'AddOrder',it's click event method is:
this.detailsview1.ChangeMode(DetailsViewMode.Insert).
a button 'UpdateOrder',it's click event method is:
this.detailsview1.ChangeMode(DetailsViewMode.Edit)
so there is a 'SaveOrder' button ,it's click event can save order object(businessObject) to database.insert or update operation.
Protected Sub SaveOrderButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveOrderButton.Click
Select Case Me.detailsview1.CurrentMode
Case DetailsViewMode.Insert
Dim ee As Csla.Web.InsertObjectArgs = New Csla.Web.InsertObjectArgs(Me.Items)
'------call csladatasource's insertobject method,but how should i build the Csla.Web.InsertObjectArgs
'----
OrderDataSource_InsertObject(sender, ee)
Exit Select
Case DetailsViewMode.Edit
Dim ee As Csla.Web.UpdateObjectArgs = New Csla.Web.UpdateObjectArgs(
'----- call csladatasource's updateobject methods
'how to call this method
OrderDataSource_UpdateObject(sender, e)
Exit Select
End Select
End Sub
How can I call csladatasource_InsertObject,csladatasource_UpdateObject methods manual,and how to build the args?
Thanks.
forrest replied on Wednesday, November 04, 2009
I got the method!thanks!
I never used databinding control and execute save operation manual.
detailsView.insertItem()
and detailsView.UpdateItem()
methods are ok.
thanks a lot!
Copyright (c) Marimer LLC