title: ASP.NET: How do "update" a field in the <EditItemTemplate> that has a null value in the database (SQL)
body: <p>I am using a FormView control.  The  allows me to update records in the database.  However, when a database field is null I can not update the field on the form. It works fine when the field is not a null value.    I am not using any code behind (C#) to bind the data or manipulate the data.  </p>
  
  <p>I have read that when there is a null value in the database that there is no record in the "dataset".  Can anyone show me how to bind a value in the form when there is a null value previously.</p>
  
  <p>Thanks,</p>
  
  <p>J </p>
  
  <p>...</p>
  
  <p>
      
      </p>
  
  <p>
      
      </p>
  
  <p><br>
      
          
              
                  
                      
                  
                  Total Records
                  
              
          
      </p>
  
  <pre><code>&lt;div style="width:1024px; text-align: justify; overflow:hidden; padding-top:0px"&gt;                   
  &lt;asp:GridView   ID="DealershipGrid" 
                  runat="server" 
                  AllowPaging="True" 
                  AllowSorting="True" 
                  AutoGenerateColumns="False" 
                  CellPadding="2" 
                  DataKeyNames="Dealership_Id" 
                  DataSourceID="DealershipsDS" 
                  ForeColor="#333333" 
                  GridLines="None" 
                  Font-Names="Tahoma" 
                  Font-Size="9pt" 
                  Font-Bold="False" 
                  Width="1024px" PageSize="10"&gt;
          &lt;PagerSettings Position="TopAndBottom" /&gt;
          &lt;FooterStyle BackColor="#8b1111" Font-Bold="True" ForeColor="White" /&gt;
          &lt;RowStyle BackColor="#FFFFFF" ForeColor="#333333" Font-Names="Tahoma" Font-Size="8pt" /&gt;
              &lt;Columns&gt;
                  &lt;asp:CommandField ShowSelectButton="True" /&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_Id" 
                          HeaderText="ID" 
                          InsertVisible="False" 
                          ReadOnly="True" 
                          SortExpression="Dealership_Id"
                          HeaderStyle-Width="3%" 
                          ItemStyle-Width="3%" 
                          FooterStyle-Width="3%" &gt;
                      &lt;FooterStyle Width="3%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="3%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="3%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_Name" 
                          HeaderText="Dealership" 
                          SortExpression="Dealership_Name" 
                          HeaderStyle-Width="18%" 
                          ItemStyle-Width="18%" 
                          FooterStyle-Width="18%"&gt;
                      &lt;FooterStyle Width="18%"&gt;&lt;/FooterStyle&gt;     
                      &lt;HeaderStyle Width="18%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="18%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_BranchName" 
                          HeaderText="Branch" 
                          SortExpression="Dealership_BranchName" 
                          HeaderStyle-Width="18%" 
                          ItemStyle-Width="18%" 
                          FooterStyle-Width="18%"&gt;
                      &lt;FooterStyle Width="18%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="18%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="18%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_Phone1" 
                          HeaderText="Phone" 
                          SortExpression="Dealership_Phone1" 
                          HeaderStyle-Width="9%" 
                          ItemStyle-Width="9%" 
                          FooterStyle-Width="9%" &gt;
                      &lt;FooterStyle Width="9%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="9%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="9%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_Email1" 
                          HeaderText="Email" 
                          SortExpression="Dealership_Email1" 
                          HeaderStyle-Width="37%" 
                          ItemStyle-Width="37%" 
                          FooterStyle-Width="37%"&gt;
                      &lt;FooterStyle Width="37%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="37%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="37%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_State" 
                          HeaderText="State" 
                          SortExpression="Dealership_State" 
                          HeaderStyle-Width="5%" 
                          ItemStyle-Width="5%" 
                          FooterStyle-Width="5%" &gt;
                      &lt;FooterStyle Width="5%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="5%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="5%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
                  &lt;asp:BoundField 
                          DataField="Dealership_ZipCode" 
                          HeaderText="Zip Code" 
                          SortExpression="Dealership_ZipCode" 
                          HeaderStyle-Width="6%" 
                          ItemStyle-Width="6%" 
                          FooterStyle-Width="6%" &gt;
                      &lt;FooterStyle Width="6%"&gt;&lt;/FooterStyle&gt;
                      &lt;HeaderStyle Width="6%" HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                      &lt;ItemStyle Width="6%"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:BoundField&gt;
              &lt;/Columns&gt;
                  &lt;PagerStyle BackColor="White" ForeColor="Maroon" HorizontalAlign="Right" /&gt;
                  &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333"  /&gt;
                  &lt;HeaderStyle BackColor="#AB1414" Font-Bold="True" ForeColor="White" Font-Names="Tahoma" Font-Size="9pt" HorizontalAlign="Left" /&gt;
                  &lt;EditRowStyle BackColor="#999999" ForeColor="Black" /&gt;
                  &lt;AlternatingRowStyle BackColor="Silver" ForeColor="Black" /&gt;
          &lt;/asp:GridView&gt;                    
  </code></pre>
  
  <p>
  
  <pre><code>    ConnectionString="&lt;%$ ConnectionStrings:driveaway2day2 %&gt;" 
      SelectCommand="SELECT [Dealership_Id], [Dealership_Name], [Dealership_BranchName], [Dealership_Phone1], [Dealership_Email1], [Dealership_State], [Dealership_ZipCode] FROM [CAR_Dealership] ORDER BY [Dealership_Name]"  EnableViewState="False" OnSelected="DealershipsDS_Selected" &gt;
  &lt;/asp:SqlDataSource&gt;                                                          
  </code></pre>
  
  <p>
  
          
          
          
          
          
              
                  
                  &nbsp; 
                  
                  
                  Dealership Details
                  
                  
                      
                          
                              
                                  &nbsp;<br>
                              
                              <br>
                                  Dealership ID
                                  &lt;%# Eval("Dealership_Id")%>
                                  Email 1
                                  &lt;%# Eval("Dealership_Email1")%>
                              
                              
                                  Dealership
                                  &lt;%# Eval("Dealership_Name")%>
                                  Email 2
                                  &lt;%# Eval("Dealership_Email2")%>
                              
                              
                                  Branch Name
                                  &lt;%# Eval("Dealership_BranchName")%>
                                  Email 3
                                  &lt;%# Eval("Dealership_Email3")%>
                              
                              
                                  Phone 1
                                  &lt;%# Eval("Dealership_Phone1")%>
                                  Address
                                  &lt;%# Eval("Dealership_Address")%>
                              
                              
                                  Phone 2
                                  &lt;%# Eval("Dealership_Phone2")%>
                                  City
                                  &lt;%# Eval("Dealership_City")%>
                              
                              
                                  Phone 3
                                  &lt;%# Eval("Dealership_Phone3")%>
                                  State
                                  &lt;%# Eval("Dealership_State")%>
                              
                              
                                  Fax
                                  &lt;%# Eval("Dealership_Fax")%>
                                  Zip Code
                                  &lt;%# Eval("Dealership_ZipCode")%>
                              
                              
                                  &nbsp;<br>
                              
                          
                      
                  </p>
  
  <pre><code>        &lt;tr&gt;
               &lt;td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"&gt;&amp;nbsp;&lt;/td&gt;              
          &lt;/tr&gt;
          &lt;tr&gt;
               &lt;td colspan="4" style="padding-top:5px;height:15px;"&gt;&amp;nbsp;&lt;/td&gt;               
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td colspan="2" style="padding-top:5px;"&gt;
                  &lt;asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" Font-Names="Tahoma" Font-Size="10px" /&gt;
                  &lt;asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" Font-Names="tahoma" Font-Size="10px" /&gt;
                  &lt;asp:Button ID="btnDelete" runat="Server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" Font-Size="10px" Font-Names="tahoma" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
   &lt;/ItemTemplate&gt;
  
      &lt;EditItemTemplate&gt;
          &lt;table border="0" width="1024px" style="padding-top:0px;"&gt;
              &lt;tr&gt;
                  &lt;td height="20px" colspan="4" style="padding-top:0px;"&gt;&amp;nbsp; &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td colspan="4" style="padding-left:3px;height:20px; background-color:#E2DED6; font-family: Tahoma; font-size:12px; color:#000000; font-weight:bold; width:1024px;"&gt;Dealership Details&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;table width="800px"&gt;
                          &lt;tr&gt;
                              &lt;td colspan="4" style="padding-top:5px;height:5px;"&gt;&amp;nbsp;&lt;/td&gt;        
                          &lt;/tr&gt;
                          &lt;tr&gt;                   
                              &lt;td style="padding-top:5px;" width="100px"&gt;Dealership ID&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;&lt;%# Eval("Dealership_Id")%&gt;&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Email 1&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox1" runat="Server" Text='&lt;%# Bind("Dealership_Email1")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Dealership&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox2" runat="Server" Text='&lt;%# Bind("Dealership_Name")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Email 2&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox3" runat="Server" Text='&lt;%# Bind("Dealership_Email2")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Branch Name&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt"  ID="TextBox4" runat="Server" Text='&lt;%# Bind("Dealership_BranchName")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Email 3&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox5"  runat="Server" Text='&lt;%# Bind("Dealership_Email3")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Phone 1&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox6" runat="Server" Text='&lt;%# Bind("Dealership_Phone1")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Address&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox7" runat="Server" Text='&lt;%# Bind("Dealership_Address")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Phone 2&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox8" runat="Server" Text='&lt;%# Bind("Dealership_Phone2")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;City&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox9" runat="Server" Text='&lt;%# Bind("Dealership_City")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Phone 3&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox10" runat="Server" Text='&lt;%# Bind("Dealership_Phone3")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;State&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:DropDownList class="aclDetDD" ID="myDropDownList" runat="server"   
                                      AppendDataBoundItems="True"  
                                      DataSourceID="StatesDS"   
                                      DataValueField="Dealership_State" 
                                      DataTextField="name"  
                                      SelectedValue='&lt;%#Bind("Dealership_State") %&gt;'&gt;  
                                      &lt;asp:ListItem Value=""&gt;Select a State...
                                      &lt;/asp:ListItem&gt;  
                                  &lt;/asp:DropDownList&gt;  
                                  &lt;asp:XmlDataSource ID="StatesDS" runat="server" DataFile="~/Ddl/States.xml"&gt;
                                  &lt;/asp:XmlDataSource&gt;                         
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Fax&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox12" runat="Server" Text='&lt;%# Bind("Dealership_Fax")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="100px"&gt;Zip Code&lt;/td&gt;
                              &lt;td style="padding-top:5px;" width="300px"&gt;
                                  &lt;asp:TextBox class="aclDetTxt" ID="TextBox13" runat="Server" Text='&lt;%# Bind("Dealership_ZipCode")%&gt;'&gt;
                                  &lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td colspan="4" style="padding-top:5px;height:5px;"&gt;&amp;nbsp;&lt;/td&gt;        
                          &lt;/tr&gt;                        
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/td&gt;
  
          &lt;tr&gt;
               &lt;td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"&gt;&amp;nbsp;&lt;/td&gt;               
          &lt;/tr&gt;
          &lt;tr&gt;
               &lt;td colspan="4" style="padding-top:5px;height:15px;"&gt;&amp;nbsp;&lt;/td&gt;                
          &lt;/tr&gt;
           &lt;asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1" ErrorMessage="Email 1 is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="TextBox2" ErrorMessage="Dealership is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="TextBox6" ErrorMessage="Phone 1 is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="TextBox7" ErrorMessage="Address is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="TextBox9" ErrorMessage="City is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="Server" ControlToValidate="TextBox13" ErrorMessage="Zip Code is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
               &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="Server" ControlToValidate="TextBox4" ErrorMessage="Branch/Location is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
              &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="Server" ControlToValidate="myDropDownList" ErrorMessage="State is Required" Text="Enter Correct Information."&gt;
              &lt;/asp:RequiredFieldValidator&gt;
          &lt;tr&gt;
              &lt;td colspan="2" style="padding-top:5px;"&gt;            
                      &lt;asp:Button ID="btnUpdate" runat="Server" CommandName="Update" Text="Update" Font-Names="tahoma" Font-Size="10px" /&gt;
                      &lt;asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;asp:ValidationSummary ID="ValidationSummary" runat="Server" ShowMessageBox="true" /&gt;
      &lt;/table&gt;
  
   &lt;/EditItemTemplate&gt;     
  </code></pre>
  
  <p>
               
                  
                      &nbsp; 
                  
                  
                  Dealership Details
                  
                  
                      
                          
                              
                                  &nbsp;<br>
                              <br>
                              <br>
                                  Dealership ID
                                  &lt;%# Eval("Dealership_Id")%>
                                  Email 1
                                  
                                      '>
                                      
                                  
                              
                              
                                  Dealership
                                  
                                      '>
                                      
                                  Email 2
                                  
                                      '>
                                      
                                  
                              
                              
                                  Branch Name
                                  
                                      '>
                                      
                                  
                                  Email 3
                                  
                                      '>
                                      
                                  
                              
                              
                                  Phone 1
                                  
                                      '>
                                      
                                  
                                  Address
                                  
                                      '>
                                      
                                  
                              
                              
                                  Phone 2
                                  
                                      '>
                                      
                                  
                                  City
                                  
                                      '>
                                      
                                  
                              
                              
                                  Phone 3
                                  
                                      '>
                                      
                                  
                                  State