- LLBLGen 2.6 Final, released on June 6th, 2008
- VS 2008, .NET 3.5, SP1
ASPX Code
-- LLBLGen ODS --
<llblgenpro:LLBLGenProDataSource2 ID="ldsData" runat="server"
AdapterTypeName="iData.DAL.DatabaseSpecific.DataAccessAdapter, iClaim.DALDBSpecific"
DataContainerType="EntityCollection"
EnableViewState="true"
EntityFactoryTypeName="iData.DAL.FactoryClasses.MyDataEntityFactory, iClaim.DAL"
onperformwork="ldsData_PerformWork"
CacheLocation="Session"
LivePersistence="False" onperformselect="ldsData_PerformSelect">
</llblgenpro:LLBLGenProDataSource2>
-- FormView --
<asp:FormView runat="server" ID="fvFROI" DataKeyNames="ID"
DataSourceID="ldsData" DefaultMode="Edit" >
<EditItemTemplate>
<asp:TextBox ID="cName" Text='<%# Bind("Name") %>'/>
-- _99 more fields bind to ODS similar to above_ --
<asp:Button ID="btnSubmit"
OnClick="btnSubmit_Click"
CommandName="Update" runat="server" Text="Submit" />
</EditItemTemplate>
.CS Code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
_id = 1; // use record 1 for testing
ldsData.Select();
}
}
protected void ldsData_PerformSelect(object sender,
SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
{
if (null != _id)
ldsData.EntityCollection = DataManager.GetDataById((int)_id);
}
protected void ldsData_PerformWork(object sender, PerformWorkEventArg2 e)
{
try
{
DataManager.Update(e.Uow);
}
catch (ORMEntityValidationExection ex)
{
// assign error msg to lErrorMsg;
// **What settings can I do in here to prevent the PerformSelect() **
// get triggered after this routine completed?
}
}
NOTE:
If I add a regular button (no commandName) in the formView. OnClick, the page get post back and PerformSelect() does not get execute. Only the Update command type button which triggered the PerformWork(). After PerformWork() completed, with exception throw, PerformSelect() get call regardless.
Should I do the entity validation in ldsData.EntityUpdated() event. If error occur, set e.cancel = true. Don't implement the ValidateEntityBeforeSave().