- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Insert Fails using FormView and LLBLGenProDataSource
Joined: 30-Dec-2006
Ok I have trie setting live persistence to True and get error from Database stating insert fails because items cannot be null. I set live persistence to false and form gets cleared when I press insert command and no communication occurs with Database.
I will attach all code Below.
<asp:FormView ID="customerFV" runat="server" Width="100%" DefaultMode="Insert"
DataKeyNames="Crid" DataSourceID="CustomerDS">
<EditItemTemplate>
CustomerNumber:
<asp:TextBox ID="CustomerNumberTextBox" runat="server"
Text='<%# Bind("CustomerNumber") %>'>
</asp:TextBox><br />
CustomerName:
<asp:TextBox ID="CustomerNameTextBox" runat="server"
Text='<%# Bind("CustomerName") %>'>
</asp:TextBox><br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server"
Text='<%# Bind("Address") %>'>
</asp:TextBox><br />
City:
<asp:TextBox ID="CityTextBox" runat="server"
Text='<%# Bind("City") %>'>
</asp:TextBox><br />
State:
<asp:TextBox ID="StateTextBox" runat="server"
Text='<%# Bind("State") %>'>
</asp:TextBox><br />
Zip:
<asp:TextBox ID="ZipTextBox" runat="server"
Text='<%# Bind("Zip") %>'>
</asp:TextBox><br />
Contact:
<asp:TextBox ID="ContactTextBox" runat="server"
Text='<%# Bind("Contact") %>'>
</asp:TextBox><br />
Telephone:
<asp:TextBox ID="TelephoneTextBox" runat="server"
Text='<%# Bind("Telephone") %>'>
</asp:TextBox><br />
Extension:
<asp:TextBox ID="ExtensionTextBox" runat="server"
Text='<%# Bind("Extension") %>'>
</asp:TextBox><br />
Itcontact:
<asp:TextBox ID="ItcontactTextBox" runat="server"
Text='<%# Bind("Itcontact") %>'>
</asp:TextBox><br />
Ittelephone:
<asp:TextBox ID="IttelephoneTextBox" runat="server"
Text='<%# Bind("Ittelephone") %>'>
</asp:TextBox><br />
Itextension:
<asp:TextBox ID="ItextensionTextBox" runat="server"
Text='<%# Bind("Itextension") %>'>
</asp:TextBox><br />
Crid:
<asp:Label ID="CridLabel1" runat="server"
Text='<%# Eval("Crid") %>'></asp:Label><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<div style="width: 99%;">
<div style="width: 49%; float: left">
OMD Number
<asp:TextBox ID="EomdTB" runat="server" Width="25%"
MaxLength="6" Height="15px" />
</div>
<div style="width: 49%; float: right">
</div>
<div style="width: 100%; float: none; text-align: center;
padding-bottom: 3px; padding-top: 3px;">
<asp:Button ID="searchButton" runat="server" Text="Search"
OnClick="searchButton_Click" />
<asp:Label ID="omdL" runat="server" BackColor="red"
Font-Bold="true" Width="100%"
Height="15px" Visible="false">No Such Customer Number
in OMD</asp:Label>
</div>
<div ID="Panel2" runat="server"
style="font-weight: bold; background-color: #c0c000;
padding-right: 10px; padding-left: 10px;
padding-bottom: 10px; padding-top: 10px;">
Specify data above to search for data or enter data below if no data
has been found.
</div>
</div>
<div style="width: 99%;">
<div style="width: 49%; float: left; padding-right: 3px;" align="center">
Name<br />
<asp:TextBox ID="EnameTB" runat="server" Width="99%"
MaxLength="75"
Text='<%# Eval("CustomerName") %>'
Height="15px" />
Address<br />
<asp:TextBox ID="EaddressTB" runat="server" Width="99%"
MaxLength="75" Text='<%# Eval("Address") %>'
Height="15px" />
City
<br />
<asp:TextBox ID="EcityTB" runat="server" Width="99%"
MaxLength="50" Text='<%# Eval("City") %>'
Height="15px" />
State
<asp:TextBox ID="EstateTB" runat="server" Width="10%"
MaxLength="2" Text='<%# Eval("State") %>'
Height="15px" />
Zip
<asp:TextBox ID="EzipTB" runat="server" Width="25%"
MaxLength="6" Text='<%# Eval("Zip") %>'
Height="15px" />
</div>
<div style="width: 49%; float: right; padding-left: 3px;" align="center">
Contact<br />
<asp:TextBox ID="EcontactTB" runat="server" Width="99%"
MaxLength="75" Text='<%# Eval("Contact") %>'
Height="15px" />
Telephone<br />
<cc1:InputMask ID="EtelephoneTB" runat="server" Width="45%"
Height="15px" MaxLength="13"
Text='<%# Eval("Telephone") %>'
Mask="(nnn)nnn-nnnn" />
<asp:TextBox ID="EextensionTB" runat="server" Width="40%"
Height="15px" MaxLength="10"
Text='<%# Eval("Extension") %>'/>
MIS Contact<br />
<asp:TextBox ID="EitcTB" runat="server" Width="99%"
MaxLength="75" Text='<%# Eval("Itcontact") %>'
Height="15px" />
MIS Telephone<br />
<cc1:InputMask ID="EittTB" runat="server" Width="45%"
Height="15px" MaxLength="13"
Text='<%# Eval("Ittelephone") %>'
Mask="(nnn)nnn-nnnn" />
<asp:TextBox ID="EiteTB" runat="server" Width="40%"
Height="15px" MaxLength="10"
Text='<%# Eval("Itextension") %>' />
</div>
<div style="width: 100%; float: none; text-align: center;
padding-bottom: 3px; padding-top: 3px;">
<asp:Label ID="ReqEntry" runat="server" BackColor="Red" Font-
Bold="True" Width="100%" Height="15px"
Visible="False"></asp:Label></div>
</div>
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
CustomerNumber:
<asp:Label ID="CustomerNumberLabel" runat="server"
Text='<%# Bind("CustomerNumber") %>'>
</asp:Label><br />
CustomerName:
<asp:Label ID="CustomerNameLabel" runat="server"
Text='<%# Bind("CustomerName") %>'>
</asp:Label><br />
Address:
<asp:Label ID="AddressLabel" runat="server"
Text='<%# Bind("Address") %>'></asp:Label><br />
City:
<asp:Label ID="CityLabel" runat="server"
Text='<%# Bind("City") %>'></asp:Label><br />
State:
<asp:Label ID="StateLabel" runat="server"
Text='<%# Bind("State") %>'></asp:Label><br />
Zip:
<asp:Label ID="ZipLabel" runat="server"
Text='<%# Bind("Zip") %>'></asp:Label><br />
Contact:
<asp:Label ID="ContactLabel" runat="server"
Text='<%# Bind("Contact") %>'></asp:Label><br />
Telephone:
<asp:Label ID="TelephoneLabel" runat="server"
Text='<%# Bind("Telephone") %>'></asp:Label><br />
Extension:
<asp:Label ID="ExtensionLabel" runat="server"
Text='<%# Bind("Extension") %>'></asp:Label><br />
Itcontact:
<asp:Label ID="ItcontactLabel" runat="server"
Text='<%# Bind("Itcontact") %>'></asp:Label><br />
Ittelephone:
<asp:Label ID="IttelephoneLabel" runat="server"
Text='<%# Bind("Ittelephone") %>'>
</asp:Label><br />
Itextension:
<asp:Label ID="ItextensionLabel" runat="server"
Text='<%# Bind("Itextension") %>'>
</asp:Label><br />
Crid:
<asp:Label ID="CridLabel" runat="server"
Text='<%# Eval("Crid") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<llblgenpro:LLBLGenProDataSource ID="CustomerDS" runat="server"
DataContainerType="EntityCollection"
EntityCollectionTypeName="MSI.SS.CollectionClasses.CustomerCollection, MSI.SS"
LivePersistence="false" >
<InsertParameters>
<asp:Parameter Name="CustomerNumber" Type="String" />
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Contact" Type="String" />
<asp:Parameter Name="Telephone" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
<asp:Parameter Name="Itcontact" Type="String" />
<asp:Parameter Name="Ittelephone" Type="String" />
<asp:Parameter Name="Itextension" Type="String" />
</InsertParameters>
</llblgenpro:LLBLGenProDataSource>
VB Code
Imports System.Data
Imports System.Data.SQLClient
Imports System.Configuration
Imports OMDDALTableAdapters
Partial Class SiteSurvey_Dispatch_NewRequest
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
End If
End Sub
Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _adapter As OMDDALTableAdapters.CUSTOMER_NAMETableAdapter = New
CUSTOMER_NAMETableAdapter
Dim _fv As FormView = customerFV
Dim _l As Label = _fv.FindControl("omdL")
Dim _tbcnum As TextBox = _fv.FindControl("EomdTB")
Dim _tbcname, _tbca, _tbcc, _tbs, _tbz, _tbcontact, _tbt As TextBox
Dim _lr As Label
Dim _cn As String = _tbcnum.Text
Dim _table As OMDDAL.CUSTOMER_NAMEDataTable = _adapter.GetOmdCustomer(_cn)
If Not _table.Count > 0 Then
_l.Visible = True
Else
_l.Visible = False
Dim _row As OMDDAL.CUSTOMER_NAMERow = _table(0)
_tbcname = _fv.FindControl("EnameTB")
_tbcname.BackColor = Drawing.Color.White
_tbcname.Text = _row.Name.Trim
_tbca = _fv.FindControl("EaddressTB")
_tbca.BackColor = Drawing.Color.White
_tbca.Text = _row.Address.Trim
_tbcc = _fv.FindControl("EcityTB")
_tbcc.BackColor = Drawing.Color.White
_tbcc.Text = _row.City.Trim
_tbs = _fv.FindControl("EstateTB")
_tbs.BackColor = Drawing.Color.White
_tbs.Text = _row.State.Trim
_tbz = _fv.FindControl("EzipTB")
_tbz.BackColor = Drawing.Color.White
_tbz.Text = _row.Zip.Trim
_tbcontact = _fv.FindControl("EcontactTB")
_tbcontact.BackColor = Drawing.Color.White
_tbcontact.Text = _row.Contact.Trim
_tbt = _fv.FindControl("EtelephoneTB")
_tbt.BackColor = Drawing.Color.White
_tbt.Text = _row.Telephone.Trim
_lr = _fv.FindControl("ReqEntry")
_lr.Visible = False
End If
End Sub
Protected Sub customerFV_ItemInserting(ByVal sender As Object, ByVal e As
FormViewInsertEventArgs) Handles customerFV.ItemInserting
If Not ValidateCustomerData(e) Then
e.Cancel = True
End If
'All Required values are set
End Sub
Protected Function ValidateCustomerData(ByVal e As FormViewInsertEventArgs)
Dim _return As Boolean = True
Dim _lr As Label
Dim _tb As TextBox
Dim _fv As FormView = customerFV
'build an array to enumerate over
Dim _a As New ArrayList
'set up all controls to test
_a.Add(_fv.FindControl("EnameTB"))
_a.Add(_fv.FindControl("EaddressTB"))
_a.Add(_fv.FindControl("EcityTB"))
_a.Add(_fv.FindControl("EstateTB"))
_a.Add(_fv.FindControl("EzipTB"))
_a.Add(_fv.FindControl("EcontactTB"))
_a.Add(_fv.FindControl("EtelephoneTB"))
'test each controle
For Each _tb In _a
'reset to white before testing
_tb.BackColor = Drawing.Color.White
'for entry
If _tb.Text.Equals("") Or _tb.Text.Equals("(___)___-____") Then
'An item is not entered invalidate the operation
_return = False
'set the background to red
_tb.BackColor = Drawing.Color.Red
End If
Next
If Not _return Then
_lr = _fv.FindControl("ReqEntry")
_lr.Text = "Required Entries have been Highlighted in Red"
_lr.Visible = True
End If
Return _return
End Function
End Class
LivePersistence = true -> please post the exact exception text and stack trace.
LivePersistence = false -> check the LLBLGen Pro manual LivePersistence and events under "Using the generated code -> Adapter/SelfServicing -> Databinding at design time and runtime -> Databinding with ASP.NET 2.0"
Joined: 30-Dec-2006
I have read the use code pages and it does not give me any specific information just talks about theory Is there some other pages am I missing some help files?
The exact trace follows.
Server Error in '/WebSite1' Application.
Cannot insert the value NULL into column 'CustomerName', table 'SiteSurvey.dbo.Customer'; column does not allow nulls. INSERT fails. The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'CustomerName', table 'SiteSurvey.dbo.Customer'; column does not allow nulls. INSERT fails. The statement has been terminated.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Cannot insert the value NULL into column 'CustomerName', table 'SiteSurvey.dbo.Customer'; column does not allow nulls. INSERT fails. The statement has been terminated.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115 SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() +324
[ORMQueryExecutionException: An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'CustomerName', table 'SiteSurvey.dbo.Customer'; column does not allow nulls. INSERT fails. The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.] SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() +589 SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute() +73 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteActionQuery(IActionQuery queryToExecute, ITransaction containingTransaction) +66 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.AddNew(IEntityFields fields, ITransaction containingTransaction) +221 MSI.SS.EntityClasses.CustomerEntity.InsertEntity() +59 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, ITransaction transactionToUse) +581 SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse) +673 MSI.SS.EntityClasses.CustomerEntity.Save(IPredicate updateRestriction, Boolean recurse) +216 SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(Boolean recurse) +114 SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView.ExecuteInsert(IDictionary values) +199 System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +68 System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation) +390 System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +609 System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +85 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4918
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
Do you fill in any value for CompanyName? As an empty value won't set the field and thus won't end up with a value inserted.
Livepersistence==false means you get an event raised (PerformWork) and you have to bind a handler to that event and persist in there, it's described in detail in the documentation for the datasourcecontrols. Though livepersistence is true should work as well.
Joined: 30-Dec-2006
I think I found the use pages you were referring to and they helped me find direct access to my entities. I can delete the current entity in the uow Object and create a new customer entity and fill the fields from the form in code behind. I shouldn't have to do that?
Joined: 30-Dec-2006
The button search OMD causes most of my data on the form to get filled from code behind. Or the user can fill the data fields manually if the customer isn't in the OMD database yet. The search button does work and fills the data.
Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _adapter As OMDDALTableAdapters.CUSTOMER_NAMETableAdapter = New CUSTOMER_NAMETableAdapter
Dim _fv As FormView = customerFV
Dim _l As Label
Dim _tbcnum As TextBox = _fv.FindControl("EomdTB")
Dim _cn As String = _tbcnum.Text
Dim _tb As TextBox
Dim _a As New ArrayList
'set up all controls to fill data to
_a.Add(_fv.FindControl("EnameTB"))
_a.Add(_fv.FindControl("EaddressTB"))
_a.Add(_fv.FindControl("EcityTB"))
_a.Add(_fv.FindControl("EstateTB"))
_a.Add(_fv.FindControl("EzipTB"))
_a.Add(_fv.FindControl("EcontactTB"))
_a.Add(_fv.FindControl("EtelephoneTB"))
'get customer data from omd if exists
Dim _table As OMDDAL.CUSTOMER_NAMEDataTable = _adapter.GetOmdCustomer(_cn)
_l = _fv.FindControl("omdL")
If Not _table.Count > 0 Then
'no such data show omd label
_l.Visible = True
Else
'data exists hide omd label
_l.Visible = False
'get the table row
Dim _row As OMDDAL.CUSTOMER_NAMERow = _table(0)
Dim _i As Integer = 1
For Each _tb In _a
'set background color to white
_tb.BackColor = Drawing.Color.White
'set text to corresponding data
_tb.Text = _row.Item(_i).ToString.Trim
_i = _i + 1
Next
'hide req entry label
_l = _fv.FindControl("ReqEntry")
_l.Visible = False
End If
End Sub
Then I user would select insert and I do some code behind to validate required fields.
Protected Sub customerFV_ItemInserting(ByVal sender As Object, ByVal e As FormViewInsertEventArgs) Handles customerFV.ItemInserting
If Not ValidateCustomerData(e) Then
e.Cancel = True
End If
'All Required values are set
End Sub
Protected Function ValidateCustomerData(ByVal e As FormViewInsertEventArgs)
Dim _return As Boolean = True
Dim _lr As Label
Dim _tb As TextBox
Dim _fv As FormView = customerFV
'build an array to enumerate over
Dim _a As New ArrayList
'set up all controls to test
_a.Add(_fv.FindControl("EnameTB"))
_a.Add(_fv.FindControl("EaddressTB"))
_a.Add(_fv.FindControl("EcityTB"))
_a.Add(_fv.FindControl("EstateTB"))
_a.Add(_fv.FindControl("EzipTB"))
_a.Add(_fv.FindControl("EcontactTB"))
_a.Add(_fv.FindControl("EtelephoneTB"))
'test each controle
For Each _tb In _a
'reset to white before testing
_tb.BackColor = Drawing.Color.White
'for entry
If _tb.Text.Equals("") Or _tb.Text.Equals("(___)___-____") Then
'An item is not entered invalidate the operation
_return = False
'set the background to red
_tb.BackColor = Drawing.Color.Red
End If
Next
If Not _return Then
_lr = _fv.FindControl("ReqEntry")
_lr.Text = "Required Entries have been Highlighted in Red"
_lr.Visible = True
End If
Return _return
End Function
So basically I have ensured that data is in the fields that are required by the database. Then I either cancel the formviewinsertingevent or let it happen and then I get the error.
Joined: 12-Feb-2004
IT looks as though LivePersistance is set to False. So you must use the PerformWork Event to save the entity with its values to the database. You are receiving an error on inserting a null value for the name so the insert is being performed I just don't see that portion of your code. Can you post the code that you have for the PerformWork eventhandler? If I've misunderstood something in this scenario just correct me.
Joined: 30-Dec-2006
I recompiled project and set up the Adapter classes now as well as the selfservicing. And I get same error for live persistence=true for both tyoes of data sources. If I understand this correctly Live persistence set to true would cause the DS object to handle the UOW object itself.
Anyway I can enumerate through the textboxes on the Formview and see that the Textbox.Text returns string values equal to what I have entered in the form.
However the SQL server still returns That the values are null.
Thanks in advance for all your help
Jeff
Cannot insert the value NULL into column 'CustomerName', table 'SiteSurvey.dbo.Customer'; column does not allow nulls. INSERT fails.
This means that the value of the CustomerName field is not set.
Would you please check the generated SQL Statement and try to run it manualy against the database?
Refer to the LLBLGen Pro docs to know how to find out the generated SQL statement: "Using the generated code -> Troubleshooting and debugging"
You do the validation in the gui. When you run the site in debug mode, do you ever reach that routine?
Does the code which checks the 'CompanyName' textbox indeed report that the textbox has a value?
When you add a requiredfield validator to the aspx page, does that help? It's really strange the field doesn't get a value set from the form.
Joined: 30-Dec-2006
Thank you for your replies I will try and figure out how to see what the generated Insert statement is. My behind code manual validation listens for the inserting event then manually checks the fields that are required to ensure that there are entries. If there are not entries in the field then I turn the background of the textboxes to red and cancel the inserting event. The SQL statement indeed has null references. But the data is there in the fields.
In my original SQLDataSource I was able to do the following:
<InsertParameters>
<asp:Parameter Name="CustomerNumber" Type="String" />
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Contact" Type="String" />
<asp:Parameter Name="Telephone" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
<asp:Parameter Name="Itcontact" Type="String" />
<asp:Parameter Name="Ittelephone" Type="String" />
<asp:Parameter Name="Itextension" Type="String" />
</InsertParameters>
Then in code behind the page I could listen to the insertingEvent and get the values out of the event itself to test them.
When I do this with the PRODSObject there are 0 items in the event. So The above statements are giving me some interesting behavior with your object. When I remove them then nothing happens of course. The fields get reset and the data gets rebound to the database but their is still no data currently bound and no select is needed here for this workflow so we go back to the default settings which would in my case be the insert template. When I add these statements then I get a SQL statement ot send to the DB but it has all null values in the statement.
The way I did this last week still works which was through a manually created DAL and BLL written in C. If I bind the Formview I have created right now with that older object data source it works just fine. So what am I missing about data binding??
I like the idea about the automatically generated code here cause if I change things in the db I just have to regenerate code and replace dlls and be done. Where as the old way I have to make a lot of manual changes to DAL and BLLs.
One thing that I am pretty sure works is I created a new entity and added it to the UOW. But the bad statement is always first to run. How do I get rid of the first item in the que. I have been trying to figure out how to change or get rid of the item in the que. VB keeps telling me that my statements are not set to an instance of an object????
I added the following to my page load handler customerDS2.FieldNamesKeepEmptyStringAsValue = _sl Where sl is a list of every field that doesn't allow null values in my DB I was expecting to be able to successfully send an object to the DB that had empty strings instead of nulls. This is not what happened I still recieved the same error NULL not allowed for CustomerName.
Also I turned on tracing and my computer is really slow now everything still working same but can't find where the output is going????
I am new to the .NET stuff I know JAVA and PERL learning .NET and vb on the fly here so I know once we figure this out it is probably something really simple.
??? Jeff
Joined: 30-Dec-2006
Otis in replie to your questions yes the code I have does validate that there is info in the field otherwise the handled event would get canceled and the back ground color of the field would get changed to red.
Now the wierd thing is that the required field validators are not working the way they should when I bind the formview to the LLBL data source but when I bind it to my old BLL datasource the reguired field validator does work????
Walaa in reply to your message This means that the value of the CustomerName field is not set. The field that is supposed to bind to the data does have text in the box. I can manually validate this in code behind but the required validator never works when bound to the LLBL object data source.
Would you please check the generated SQL Statement and try to run it manualy against the database? I have set the system.diagnostics keys for debugging but I am not sure where the output is going. My computer is running really slowly though when I have those keys added to the web.config.
I am very new to ASP.NET and your object. Sorry
Joined: 12-Feb-2004
I have set the system.diagnostics keys for debugging but I am not sure where the output is going. My computer is running really slowly though when I have those keys added to the web.config.
When debugging your application you will have an output window. This is where the information is shown. If you do not see it when debugging the go to View->Output in Visual Studio.
JeffM wrote:
Otis in replie to your questions yes the code I have does validate that there is info in the field otherwise the handled event would get canceled and the back ground color of the field would get changed to red.
Now the wierd thing is that the required field validators are not working the way they should when I bind the formview to the LLBL data source but when I bind it to my old BLL datasource the reguired field validator does work????
The llblgenprodatasource control isn't the same as the sqldatasource control. Your code now binds to the formview's inserting event, and if that event is raised after the formview calls ExecuteInsert() on the llblgenprodatasource control, the data is already going to the db. The sqldatasource control has an inserting event though the llblgenprodatasource control doesn't.
The only way you can be sure the validation code is called, is by using a debugger.
Now, validation as you're doing can be done more efficient through asp.net validators. This way you can leave the management of validation etc. to asp.net. You can also opt for a validator class as described in 'Using the generated code - Validation per field or per entity'.
Though I think I found what's the problem: the InsertParameters.
You have:
<InsertParameters>
<asp:Parameter Name="CustomerNumber" Type="String" />
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Contact" Type="String" />
<asp:Parameter Name="Telephone" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
<asp:Parameter Name="Itcontact" Type="String" />
<asp:Parameter Name="Ittelephone" Type="String" />
<asp:Parameter Name="Itextension" Type="String" />
</InsertParameters>
But that's not necessary. InsertParameters with llblgenprodatasource controls are used to insert a value retrieved from somewhere else, like querystring, a form variable, another control etc. As you define it, CustomerNumber, CustomerName etc. will always be empty. So please remove the <InsertParameters> element, as you don't need it.
Joined: 30-Dec-2006
I apologize that I am having so much trouble with this issue. My db right now is empty there is no data. The workflow I am working on here is to input a new request for connection services. so eventually there will be Customer info, Equipment info, Request info all on same web pae and the insert will need to insert into all three tables which will be nice using the UOW object. I just am trying to get one insert into one tableto work before I continue to do the rest. I looked at the output window and there is no output there. Here is my web.config file.
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings>
<add key="SS.Self.ConnectionString" value="data source=Woodstock;initial catalog=SiteSurvey;integrated security=SSPI;persist security info=False;packet size=4096"/>
<add key="SS.Adapter.ConnectionString" value="data source=Woodstock;initial catalog=SiteSurvey;integrated security=SSPI;persist security info=False;packet size=4096"/>
</appSettings>
<connectionStrings>
<add name="SiteSurveyConnectionString" connectionString="Data Source=WOODSTOCK;Initial Catalog=SiteSurvey;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="OMDConnectionString" connectionString="Data Source=WOODSTOCK;Initial Catalog=OMD;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.diagnostics>
<switches>
<add name="SqlServerDQE" value="4" />
<add name="ORMGeneral" value="4" />
<add name="ORMStateManagement" value="4" />
<add name="ORMPersistenceExecution" value="4" />
</switches>
</system.diagnostics>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages masterPageFile="~/Main.master" theme="Blue">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpModules>
<add name="MagicAjax" type="MagicAjax.MagicAjaxModule, MagicAjax"/>
</httpModules>
</system.web>
</configuration>
The page I am having troube with.
<%@ Page Language="VB" MasterPageFile="~/Main.master" AutoEventWireup="false" CodeFile="NewRequest.aspx.vb" Inherits="SiteSurvey_Dispatch_NewRequest" title="Dispatch:New Request" %>
<%@ Register Assembly="AssistedSolutions.WebControls.InputMask" Namespace="AssistedSolutions.WebControls"
TagPrefix="cc1" %>
<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses"
TagPrefix="llblgenpro" %>
<%@ Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAjax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP1" Runat="Server">
<div id="adminedit" style="font-size:13px;">
<ajax:AjaxPanel ID="AjaxPanel1" runat="server" Height="100%" Width="100%">
<div class="formsection">New Request</div>
<div class="wrapper2">
<div class="left2">
<div class="row">
<fieldset>
<legend align="center">Customer Information</legend>
<asp:FormView ID="customerFV" runat="server" Width="100%" DefaultMode="Insert" DataKeyNames="Crid" DataSourceID="customerDS2">
<EditItemTemplate>
CustomerNumber:
<asp:TextBox ID="CustomerNumberTextBox" runat="server" Text='<%# Bind("CustomerNumber") %>'>
</asp:TextBox><br />
CustomerName:
<asp:TextBox ID="CustomerNameTextBox" runat="server" Text='<%# Bind("CustomerName") %>'>
</asp:TextBox><br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>'>
</asp:TextBox><br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>'>
</asp:TextBox><br />
State:
<asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>'>
</asp:TextBox><br />
Zip:
<asp:TextBox ID="ZipTextBox" runat="server" Text='<%# Bind("Zip") %>'>
</asp:TextBox><br />
Contact:
<asp:TextBox ID="ContactTextBox" runat="server" Text='<%# Bind("Contact") %>'>
</asp:TextBox><br />
Telephone:
<asp:TextBox ID="TelephoneTextBox" runat="server" Text='<%# Bind("Telephone") %>'>
</asp:TextBox><br />
Extension:
<asp:TextBox ID="ExtensionTextBox" runat="server" Text='<%# Bind("Extension") %>'>
</asp:TextBox><br />
Itcontact:
<asp:TextBox ID="ItcontactTextBox" runat="server" Text='<%# Bind("Itcontact") %>'>
</asp:TextBox><br />
Ittelephone:
<asp:TextBox ID="IttelephoneTextBox" runat="server" Text='<%# Bind("Ittelephone") %>'>
</asp:TextBox><br />
Itextension:
<asp:TextBox ID="ItextensionTextBox" runat="server" Text='<%# Bind("Itextension") %>'>
</asp:TextBox><br />
Crid:
<asp:Label ID="CridLabel1" runat="server" Text='<%# Eval("Crid") %>'></asp:Label><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<div style="width: 99%;">
<div style="width: 49%; float: left">
OMD Number
<asp:TextBox ID="EomdTB" runat="server" Width="25%" MaxLength="6" Height="15px" BackColor="White" />
</div>
<div style="width: 49%; float: right">
</div>
<div style="width: 100%; float: none; text-align: center; padding-bottom: 3px; padding-top: 3px;">
<asp:Button ID="searchButton" runat="server" Text="Search" OnClick="searchButton_Click" />
<asp:Label ID="omdL" runat="server" BackColor="red" Font-Bold="true" Width="100%"
Height="15px" Visible="false">No Such Customer Number inOMD</asp:Label>
</div>
<div ID="Panel2" runat="server"
style="font-weight: bold; background-color: #c0c000; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px;">
Specify data above to search for data or enter data below if no data has been found.
</div>
</div>
<div style="width: 99%;">
<div style="width: 49%; float: left; padding-right: 3px;" align="center">
Name<br />
<asp:TextBox ID="EnameTB" runat="server" Width="99%" MaxLength="75" Text='<%# Bind("CustomerName") %>' Height="15px" BackColor="White" />
Address<br />
<asp:TextBox ID="EaddressTB" runat="server" Width="99%" MaxLength="75" Text='<%# Bind("Address") %>' Height="15px" BackColor="White" />
City
<br />
<asp:TextBox ID="EcityTB" runat="server" Width="99%" MaxLength="50" Text='<%# Bind("City") %>' Height="15px" BackColor="White" />
State
<asp:TextBox ID="EstateTB" runat="server" Width="10%" MaxLength="2" Text='<%# Bind("State") %>' Height="15px" BackColor="White" />
Zip
<asp:TextBox ID="EzipTB" runat="server" Width="25%" MaxLength="6" Text='<%# Bind("Zip") %>' Height="15px" BackColor="White" />
</div>
<div style="width: 49%; float: right; padding-left: 3px;" align="center">
Contact<br />
<asp:TextBox ID="EcontactTB" runat="server" Width="99%" MaxLength="75" Text='<%# Bind("Contact") %>' Height="15px" BackColor="White" />
Telephone<br />
<cc1:InputMask ID="EtelephoneTB" runat="server" Width="45%" Height="15px" MaxLength="13" Text='<%# Bind("Telephone") %>'
Mask="(nnn)nnn-nnnn" BackColor="White" />
<asp:TextBox ID="EextensionTB" runat="server" Width="40%" Height="15px" MaxLength="10" Text='<%# Bind("Extension") %>' BackColor="White"/>
MIS Contact<br />
<asp:TextBox ID="EitcTB" runat="server" Width="99%" MaxLength="75" Text='<%# Bind("Itcontact") %>' Height="15px" BackColor="White" />
MIS Telephone<br />
<cc1:InputMask ID="EittTB" runat="server" Width="45%" Height="15px" MaxLength="13" Text='<%# Bind("Ittelephone") %>'
Mask="(nnn)nnn-nnnn" BackColor="White" />
<asp:TextBox ID="EiteTB" runat="server" Width="40%" Height="15px" MaxLength="10" Text='<%# Bind("Itextension") %>' BackColor="White" />
</div>
<div style="width: 100%; float: none; text-align: center; padding-bottom: 3px; padding-top: 3px;">
<asp:Label ID="ReqEntry" runat="server" BackColor="Red" Font-Bold="True" Width="100%" Height="15px"
Visible="False"></asp:Label></div>
</div>
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Clear">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
CustomerNumber:
<asp:Label ID="CustomerNumberLabel" runat="server" Text='<%# Bind("CustomerNumber") %>'>
</asp:Label><br />
CustomerName:
<asp:Label ID="CustomerNameLabel" runat="server" Text='<%# Bind("CustomerName") %>'>
</asp:Label><br />
Address:
<asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>'></asp:Label><br />
City:
<asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>'></asp:Label><br />
State:
<asp:Label ID="StateLabel" runat="server" Text='<%# Bind("State") %>'></asp:Label><br />
Zip:
<asp:Label ID="ZipLabel" runat="server" Text='<%# Bind("Zip") %>'></asp:Label><br />
Contact:
<asp:Label ID="ContactLabel" runat="server" Text='<%# Bind("Contact") %>'></asp:Label><br />
Telephone:
<asp:Label ID="TelephoneLabel" runat="server" Text='<%# Bind("Telephone") %>'></asp:Label><br />
Extension:
<asp:Label ID="ExtensionLabel" runat="server" Text='<%# Bind("Extension") %>'></asp:Label><br />
Itcontact:
<asp:Label ID="ItcontactLabel" runat="server" Text='<%# Bind("Itcontact") %>'></asp:Label><br />
Ittelephone:
<asp:Label ID="IttelephoneLabel" runat="server" Text='<%# Bind("Ittelephone") %>'>
</asp:Label><br />
Itextension:
<asp:Label ID="ItextensionLabel" runat="server" Text='<%# Bind("Itextension") %>'>
</asp:Label><br />
Crid:
<asp:Label ID="CridLabel" runat="server" Text='<%# Eval("Crid") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<llblgenpro:LLBLGenProDataSource ID="CustomerDS" runat="server" DataContainerType="EntityCollection"
EntityCollectionTypeName="MSI.SS.Self.CollectionClasses.CustomerCollection, MSI.SS.Self"
LivePersistence="true" >
<InsertParameters>
<asp:Parameter Name="CustomerNumber" Type="String" />
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Contact" Type="String" />
<asp:Parameter Name="Telephone" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
<asp:Parameter Name="Itcontact" Type="String" />
<asp:Parameter Name="Ittelephone" Type="String" />
<asp:Parameter Name="Itextension" Type="String" />
</InsertParameters>
</llblgenpro:LLBLGenProDataSource>
<llblgenpro:LLBLGenProDataSource2 ID="customerDS2" runat="server" AdapterTypeName="MSI.SS.Adapter.DatabaseSpecific.DataAccessAdapter, MSI.SS.AdapterDBSpecific"
DataContainerType="EntityCollection" EntityFactoryTypeName="MSI.SS.Adapter.FactoryClasses.CustomerEntityFactory, MSI.SS.Adapter">
<InsertParameters>
<asp:Parameter Name="CustomerNumber" Type="String" />
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Contact" Type="String" />
<asp:Parameter Name="Telephone" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
<asp:Parameter Name="Itcontact" Type="String" />
<asp:Parameter Name="Ittelephone" Type="String" />
<asp:Parameter Name="Itextension" Type="String" />
</InsertParameters>
</llblgenpro:LLBLGenProDataSource2>
</fieldset>
</div>
</div>
</div>
</ajax:AjaxPanel>
</div>
</asp:Content>
The code behind the page I am having trouble with.
Imports System.Data
Imports System.Collections.Generic
Imports System.Data.SQLClient
Imports System.Configuration
Imports OMDDALTableAdapters
Imports SD.LLBLGen.Pro.ORMSupportClasses
Imports MSI.SS.Self.EntityClasses
Partial Class SiteSurvey_Dispatch_NewRequest
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim _sl As New List(Of String)()
_sl.Add("CustomerName")
CustomerDS.FieldNamesKeepEmptyStringAsValue = _sl
customerDS2.FieldNamesKeepEmptyStringAsValue = _sl
End If
End Sub
Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _adapter As OMDDALTableAdapters.CUSTOMER_NAMETableAdapter = New CUSTOMER_NAMETableAdapter
Dim _fv As FormView = customerFV
Dim _l As Label
Dim _tbcnum As TextBox = _fv.FindControl("EomdTB")
Dim _cn As String = _tbcnum.Text
Dim _tb As TextBox
Dim _a As New ArrayList
'set up all controls to fill data to
_a.Add(_fv.FindControl("EnameTB"))
_a.Add(_fv.FindControl("EaddressTB"))
_a.Add(_fv.FindControl("EcityTB"))
_a.Add(_fv.FindControl("EstateTB"))
_a.Add(_fv.FindControl("EzipTB"))
_a.Add(_fv.FindControl("EcontactTB"))
_a.Add(_fv.FindControl("EtelephoneTB"))
'get customer data from omd if exists
Dim _table As OMDDAL.CUSTOMER_NAMEDataTable = _adapter.GetOmdCustomer(_cn)
_l = _fv.FindControl("omdL")
If Not _table.Count > 0 Then
'no such data show omd label
_l.Visible = True
Else
'data exists hide omd label
_l.Visible = False
'get the table row
Dim _row As OMDDAL.CUSTOMER_NAMERow = _table(0)
Dim _i As Integer = 1
For Each _tb In _a
'set background color to white
_tb.BackColor = Drawing.Color.White
'set text to corresponding data
_tb.Text = _row.Item(_i).ToString.Trim
_i = _i + 1
Next
'hide req entry label
_l = _fv.FindControl("ReqEntry")
_l.Visible = False
End If
End Sub
Protected Sub customerDS_PerformingWork(ByVal sender As Object, ByVal e As PerformWorkEventArgs) Handles CustomerDS.PerformWork
MsgBox("DS Performing work")
End Sub
Protected Sub customerFV_ItemInserting(ByVal sender As Object, ByVal e As FormViewInsertEventArgs) Handles customerFV.ItemInserting
If Not ValidateCustomerData(e) Then
e.Cancel = True
End If
'All Required values are set
End Sub
Protected Function ValidateCustomerData(ByVal e As FormViewInsertEventArgs)
Dim _return As Boolean = True
Dim _lr As Label
Dim _tb As TextBox
Dim _fv As FormView = customerFV
'build an array to enumerate over
Dim _a As New ArrayList
'set up all controls to test
_a.Add(_fv.FindControl("EnameTB"))
_a.Add(_fv.FindControl("EaddressTB"))
_a.Add(_fv.FindControl("EcityTB"))
_a.Add(_fv.FindControl("EstateTB"))
_a.Add(_fv.FindControl("EzipTB"))
_a.Add(_fv.FindControl("EcontactTB"))
_a.Add(_fv.FindControl("EtelephoneTB"))
'test each controle
For Each _tb In _a
'reset to white before testing
_tb.BackColor = Drawing.Color.White
'for entry
If _tb.Text.Equals("") Or _tb.Text.Equals("(___)___-____") Then
'An item is not entered invalidate the operation
_return = False
'set the background to red
_tb.BackColor = Drawing.Color.Red
End If
Next
If Not _return Then
_lr = _fv.FindControl("ReqEntry")
_lr.Text = "Required Entries have been Highlighted in Red"
_lr.Visible = True
End If
Return _return
End Function
End Class
These are the things I have noticed. If I set live persistence to false then nothing happens. For obvious reasons I haven't coded anything for the raised event.
If I set Live persistence to tru then either the form gets cleared and no data gets entered to the db instead of going to the ItemDetail formview after data has been entered. This happens if I give no insert paramaeters to the data source object.
If I give insert parameters to the DS object then I get null references. Even though the insert parameters are pointing to the bound controls in the form just like I would do for the DAL/BLL Object Data Source control I have used previously.
Thanks any advice is welcome.
JeffM wrote:
Otis this sounds really great. However, If I remove the Insert parameters from the from DataSource control then no communication occurs between the DB and the .net?
No, that's not the case, the insert parameters for llblgenprodatasource(2) controls are used only when the value you want to insert for a given field isn't available in the form. So if you have the fields in the form, you don't need hte insertparameters. In in general, you don't need them unless you for example want to set an FK with the value frm a combobox outside the formview for example.
LLBLGenProDataSource(2) controls are smarter than their default cousins, they can figure out which form fields to insert in which entity field
Joined: 30-Dec-2006
Otis I understand what you are telling me and I got that same information from the using code help pages however. I am telling you that when I remove that code from the LLBLGenProDataSource(1) object that NOTHING happens. When I press the insert button I step into my server side code and my manual validation occurs for the form to verify that fields are entered properly. Then what should happen is the data would get sent to the DB and the formview would enter ItemTemplate and show the data just entered. However this is not what happens. I do not know if any communication occurs between the db and ASP or not because I have not figured out how to get the debug options to work. I have all the lines in my web.config file and I have gone to the output console to see if there is any output but absolutely nothing shows up. What does happen is the formview get cleared of all data and I am still on the insertTemplate view. I go and check the DB manuallt and there is no new data in my table. I understand if you guys don't want to helpme anymore because I am new to ASP, VB, and LLBL coding and I am not a paying customer. Also as far as deadlines go I am approaching it. My work MetroSales Inc does have the full version of this product and He just sent me an example of a working page so I will take a look at it. I have tried to look at examples given on your website and downloadable version of the tutorials but I have not seen any insert code specifically for ASP.NET 2.0 Only Windows Form Applications. I already have this workflow that I am working on working the old way so I am just trying to work with your object because of the self generated Business logic.
In the HnD sourcecode (this forum system), admin section, ManageIPBans form, you can check how it's done. The HnD sourcecode is available at http://www.llblgen.com/hnd/ It's fairly straight forward. I don't use an event handler on the formview there, though it does illustrate how to use the datasourcecontrol and a formview for editing and inserting data.
Joined: 30-Dec-2006
Ok so I started again from scratch. Formview with default setup and ObjecDataSource1 with default setup and it worked inserting a new item to the db. No validation of form yet. When I press insert the insert action is performed and the DB gets the data... YEAH!!!
However I would like after that happens then to view the data I just put in. In the formview but what happens is the form is cleared.
I looked at the ManageIPBans page and you are using buttons to switch the views back and forth is that a best practice with your controls?
Jeff
Joined: 15-Jul-2005
JeffM wrote:
However I would like after that happens then to view the data I just put in. In the formview but what happens is the form is cleared.
Have you tried calling the ChangeMode() method after your insert completes?
JeffM wrote:
Ok so I started again from scratch. Formview with default setup and ObjecDataSource1 with default setup and it worked inserting a new item to the db. No validation of form yet. When I press insert the insert action is performed and the DB gets the data... YEAH!!!
However I would like after that happens then to view the data I just put in. In the formview but what happens is the form is cleared.
I looked at the ManageIPBans page and you are using buttons to switch the views back and forth is that a best practice with your controls?
Jeff
The button is necessary as the formview is bound to the same datasource control as the grid is and it's set by default on Edit mode. This means that if there's no row in the grid, the formview won't show! .
If you have set it to Insert by default, the button isnt necessary, though you have to automatically switch to edit when you click select on the grid row.
Joined: 30-Dec-2006
Ok I am starting to make some good steps towards a working formview now. Inserting deleting and editing works. The reason that it stayed on insert mode is that I needed to only change to insert mode if page wasn't a postback.
Anyway so now that I have it working for an insert. It switches Modes and displays the first record in the db. How can I get the Primary Key returned to me so I can show the record just inserted?
Jeff
Anyway so now that I have it working for an insert. It switches Modes and displays the first record in the db. How can I get the Primary Key returned to me so I can show the record just inserted?
You can get back the PK if you were doing the saves yourself (LivePersistence = flase)