I have a form view which does the basic insert functionality .However if i pass an empty string "" in the textbox of form view ,it gets converted to NULL .I am only able to insert if i pass a string " " like this .My database is SQL Server and some columns cannot be NULL,however i cannot send " " with an extra blank space.I have done the following code in ItemCreated event of FormView
Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.ItemCreated
If FormView1.CurrentMode = FormViewMode.Insert Then
Dim WARFRAN As TextBox = DirectCast(FormView1.FindControl("WARFRANTextBox"), TextBox)
If WARFRAN IsNot Nothing Then
WARFRAN.Text = ""
End If
End Sub
for my grid view i could find a property like ConvertEmptyStringToNull="false"
but i couldnt find such a command for form view
I found the answer ,in my aspx page in the form view code there is a section called
InsertParameters ,in that to each parameter we can give ConvertEmptyStringToNull="false"
<InsertParameters>
<asp:Parameter Name="WARSTTS" Type="String" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="WARFRAN" Type="String" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="WARUSID" Type="String" ConvertEmptyStringToNull="false" />
</InsertParameters>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With