Note that there are some explanatory texts on larger screens.

plurals
  1. PODetailsView converts TextBoxes empty string to null
    primarykey
    data
    text
    <p>I have a basic ASP.NET Web Forms application.</p> <p>I give the user the possibility to create the records by using a <strong>Web Form</strong> and to update them by using a <strong>DetailsView</strong>.</p> <p>The web form stores the empty field on the <strong>TextBoxes</strong> as *<em>empty strin</em>*g in the DB correctly.</p> <p>The <strong>DetailsView</strong> instead stores them as <strong>null</strong> fields in the DB.</p> <p>Moreover in the <strong>DetailsView_ItemUpdated</strong> event if I check the <strong>e.newvalues</strong> and <strong>e.oldvalues</strong> arguments the corresponding fields are null as well (throwing an exception) that means the data are already sent as null to the server upon submit.</p> <p>In the <strong>DetailsView</strong> I use templates and I set all Update parameters in the <strong>SQLDataSource</strong> as <strong>ConvertEmptyStringToNull="false"</strong>. </p> <p><strong>SQLDataSource parameter</strong>:</p> <pre><code>&lt;asp:Parameter Name="SHELF" Type="String" ConvertEmptyStringToNull="false"/&gt; </code></pre> <p><strong>DetailsView</strong></p> <pre><code> &lt;asp:DetailsView runat="server" ID="GvProductDetail" AutoGenerateRows="False" DataKeyNames="rowid" DataSourceID="ProductDetailData" OnItemUpdated="gvProductDetail_ItemUpdated"&gt; &lt;asp:TemplateField&gt; &lt;HeaderTemplate&gt;Stock Shelf &amp;nbsp;&lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;%# Eval("Shelf") %&gt; &lt;/ItemTemplate&gt; &lt;EditItemTemplate&gt; &lt;asp:TextBox runat="server" ID="txtShelf" Text='&lt;%# Bind("Shelf") %&gt;' &gt;&lt;/asp:TextBox&gt; &lt;/EditItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>Is that possible that Bind converts the empty values to null? I thought it was enough to set the UpdateParameters rule not to convert empty string to null but apprently there is some other surprise. anybody might help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload