Formview onUpdating
Jeg sidder og har et lille problem med noget ASP som jeg sidder og laver lige for tiden...Jeg får hele tiden "Cannot insert the value NULL into column 'ADDRESS1', table 'CUSTOMER'; column does not allow nulls. UPDATE fails.
The statement has been terminated."
Jeg har forkortet selve Design kode delen men det burde være muligt at kunne se hvad der sker... onUpdating er lavet for at fjerne Null værdier men af en eller anden grund vil den ikke se den ændring.. håber nogen kan hjælpe mig :)
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2" DataKeyNames="ROWNUMBER" OnItemUpdating="ItemUpdate">
<EditItemTemplate>
<table style="width: 420px" class="formView">
<tr>
<td colspan="2" class="caption">
</td>
</tr>
<tr>
<td style="width: 25%">
Konto:
</td>
<td>
<asp:TextBox ID="ACCOUNTTextBox" runat="server" Text='<%# Bind("ACCOUNT") %>' />
</td>
</tr>
<tr>
<td>
Navn:
</td>
<td>
<asp:TextBox ID="NAMETextBox" runat="server" Text='<%# Bind("NAME") %>' />
</td>
</tr>
<tr>
<td>
Adresse:
</td>
<td>
<asp:TextBox ID="ADDRESS1TextBox" runat="server" Text='<%# Bind("ADDRESS1") %>' />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:TextBox ID="ADDRESS2TextBox" runat="server" Text='<%# Bind("ADDRESS2") %>' />
</td>
</tr>
<tr>
<td>
Postnr/By:
</td>
<td>
<asp:TextBox ID="ZIPCITYTextBox" runat="server" Text='<%# Bind("ZIPCITY") %>' />
</td>
</tr>
<tr>
<td>
Land:
</td>
<td>
<asp:TextBox ID="COUNTRYTextBox" runat="server" Text='<%# Bind("COUNTRY") %>' />
</td>
</tr>
<tr>
<td>
Gruppe:
</td>
<td>
<asp:TextBox ID="GROUP_TextBox" runat="server" Text='<%# Bind("GROUP_") %>' />
</td>
</tr>
<tr>
<td>
Fak.konto:
</td>
<td>
<asp:TextBox ID="INVOICEACCOUNTTextBox" runat="server" Text='<%# Bind("INVOICEACCOUNT") %>' />
</td>
</tr>
...
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:C5_DBFConnectionString %>"
SelectCommand="SELECT * FROM CUSTTABLE_CLEAN WHERE (ROWNUMBER = @ROWNUMBER)"
UpdateCommand="UPDATE C5SQLadmin_DBF.CUSTTABLE SET ACCOUNT = @ACCOUNT, NAME = @NAME, ADDRESS1 = @ADDRESS1, ADDRESS2 = @ADDRESS2, ZIPCITY = @ZIPCITY, COUNTRY = @COUNTRY, ATTENTION = @ATTENTION, PHONE = @PHONE, FAX = @FAX, GROUP_ = @GROUP_, EMAIL = @EMAIL, CELLPHONE = @CELLPHONE, PAYMENT = @PAYMENT, INVOICEACCOUNT = @INVOICEACCOUNT, PDFRYKPROFIL = @PDFRYKPROFIL WHERE (ROWNUMBER = @ROWNUMBER)">
<SelectParameters>
<asp:ControlParameter ControlID="RadComboBox1" Name="ROWNUMBER" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ACCOUNT" />
<asp:Parameter Name="NAME" />
<asp:Parameter Name="ADDRESS1" />
<asp:Parameter Name="ADDRESS2" />
<asp:Parameter Name="ZIPCITY" />
...
Sub ItemUpdate(ByVal source As FormView, ByVal e As FormViewUpdateEventArgs) Handles FormView1.ItemUpdating
For Each item As DictionaryEntry In e.NewValues
If Not item.Value = Nothing Then
item.Value = item.Value
Else
item.Value = Chr(2)
End If
Next
End Sub