3

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

krishna
  • 241
  • 1
  • 5
  • 18
  • Not sure whether [this](https://stackoverflow.com/questions/753455/formview-convertemptystringtonull-and-binding) would be useful or not. – jmcilhinney Jun 04 '20 at 05:52

1 Answers1

1

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>
krishna
  • 241
  • 1
  • 5
  • 18