title: Convertemptystringtonull not working in gridview
body: <p>I'm trying to convert an empty string to null when editing a table in my gridview. I've tried several iterations and methods with no success. I'm suspecting that the issues is in my <code>ObjectDataSource</code> but don't know the correct syntax I need.  </p>
  
  <pre><code>&lt;asp:GridView 
      ID="grdMyDistributors"
      DataSourceID = "srcGetMyDistributors" 
      CssClass="GridViewStyle"
      DataKeyNames = "ID_Distributor"
      AutoGenerateColumns = "false" AutoGenerateEditButton = "true"
      GridLines="None"
      runat="server" &gt;
      &lt;Columns&gt;
      &lt;asp:BoundField
          DataField="DistributorName"
          HeaderText="Distributor" 
          convertemptystringtonull="true"
          ReadOnly = "True" /&gt;
      &lt;asp:BoundField
          DataField="Distributor_Email_1"
          HeaderText="Distributor Email 1"
          convertemptystringtonull="true" &gt;
          &lt;ItemStyle BackColor="#f6f17c"/&gt;
      &lt;/asp:BoundField&gt;
      &lt;asp:BoundField
          DataField="Distributor_Email_2"
          HeaderText="Distributor Email 2"
          convertemptystringtonull="true" &gt;
          &lt;ItemStyle BackColor="#f6f17c"/&gt;
      &lt;/asp:BoundField&gt;
      &lt;asp:BoundField
          DataField="Minimum_Purchase_Amount"
          HeaderText="Minimum Purchase Amount"
          dataformatstring="{0:c}"
          convertemptystringtonull="true" &gt;
          &lt;ItemStyle BackColor="#f6f17c" /&gt;
      &lt;/asp:BoundField&gt;
      &lt;/Columns&gt; 
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is my <code>ObjectDataSource</code>:</p>
  
  <pre><code>    &lt;asp:ObjectDataSource 
          ID="srcGetMyDistributors" 
          TypeName = "AAA.Distributors"
          SelectMethod = "GetDistributorsPagingFiltered"
          UpdateMethod = "UpdateDistributors"
          EnableCaching="false"
          ConvertNulltoDBNull = "true"
          runat="server" &gt;
          &lt;SelectParameters&gt;
              &lt;asp:ProfileParameter Name="ID_Account" PropertyName="ID_Account" /&gt;
          &lt;/SelectParameters&gt;
          &lt;UpdateParameters&gt;
              &lt;asp:ControlParameter ControlID="grdMyDistributors" Name="ID_Distributor" PropertyName="SelectedValue" Type="Int32" /&gt;
          &lt;/UpdateParameters&gt;
      &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>Here is my update method</p>
  
  <pre><code>    Public Shared Sub UpdateDistributors(ByVal ID_Distributor As Integer, ByVal Distributor_Email_1 As String, ByVal Distributor_Email_2 As String, ByVal Minimum_Purchase_Amount As Decimal)
          ' Initialize command
          Dim con As New SqlConnection(_connectionString)
          Dim cmd As New SqlCommand("UpdateDistributors", con)
          cmd.CommandType = CommandType.StoredProcedure
          cmd.Connection = con
  
          ' Initialize parameters
          cmd.Parameters.AddWithValue("@ID_Distributor", A2AID_Restaurant_To_Distributor)
          cmd.Parameters.AddWithValue("@Distributor_Email_1", Distributor_Email_1)
          cmd.Parameters.AddWithValue("@Distributor_Email_2", Distributor_Email_2)
          cmd.Parameters.AddWithValue("@Minimum_Purchase_Amount", Minimum_Purchase_Amount)
  
          ' Execute command
          Using (con)
              con.Open()
              cmd.ExecuteNonQuery()
          End Using
  
      End Sub
  </code></pre>
  
  <p>When I run the code as is, I get an error saying "Object of type 'System.DBNull' cannot be converted to type 'System.String'."  It's most likely erroring when it's trying to send to the Update method and expecting a string.  If I take out "ConvertNulltoDBNull = "true"  from the ObjectDataSource it complains that the SQL statement is expecting a value (meaning it's not sending the Null).  I've tried so many variations of this and can't find any info in the class library.  Any help would be greatly appreciated!</p>
  
  <p>Thanks in advance!</p>