473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How do "update" a field in the <EditItemTemplate> that has a null value in t

Hi All,

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.

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.

Thanks,

J



...
Expand|Select|Wrap|Line Numbers
  1. <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
  2.     <meta name="description" content="" />
  3. </asp:Content>    
  4.  
  5. <asp:Content ID="Content4" ContentPlaceHolderID="PageTitle" Runat="Server">
  6.     <asp:TextBox ID="TextTitle" runat="server" BorderStyle="None" Font-Bold="True" 
  7.         Font-Names="Arial" Font-Size="18px"></asp:TextBox>
  8. </asp:Content>    
  9.  
  10. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">    
  11.     <div style="position:absolute; top:230px;left:600px;width:400px">
  12.         <table cellpadding="0" cellspacing="0">
  13.             <tr>
  14.                 <td width="50px" align="right">
  15.                     <asp:TextBox ID="RecordCounter" runat="server" BorderStyle="None" 
  16.                         Font-Bold="True" Font-Names="Tahoma" Font-Size="9pt" ForeColor="#AB1414" 
  17.                         Width="50px"></asp:TextBox>
  18.                 </td>
  19.                 <td style="Font-Family:Tahoma; font-size:12px; font-weight:bold; color:#000000;" 
  20.                     align="left">Total Records
  21.                 </td>
  22.             </tr>
  23.         </table>
  24.     </div>
  25.  
  26.     <div style="width:1024px; text-align: justify; overflow:hidden; padding-top:0px">                   
  27.     <asp:GridView   ID="DealershipGrid" 
  28.                     runat="server" 
  29.                     AllowPaging="True" 
  30.                     AllowSorting="True" 
  31.                     AutoGenerateColumns="False" 
  32.                     CellPadding="2" 
  33.                     DataKeyNames="Dealership_Id" 
  34.                     DataSourceID="DealershipsDS" 
  35.                     ForeColor="#333333" 
  36.                     GridLines="None" 
  37.                     Font-Names="Tahoma" 
  38.                     Font-Size="9pt" 
  39.                     Font-Bold="False" 
  40.                     Width="1024px" PageSize="10">
  41.             <PagerSettings Position="TopAndBottom" />
  42.             <FooterStyle BackColor="#8b1111" Font-Bold="True" ForeColor="White" />
  43.             <RowStyle BackColor="#FFFFFF" ForeColor="#333333" Font-Names="Tahoma" Font-Size="8pt" />
  44.                 <Columns>
  45.                     <asp:CommandField ShowSelectButton="True" />
  46.                     <asp:BoundField 
  47.                             DataField="Dealership_Id" 
  48.                             HeaderText="ID" 
  49.                             InsertVisible="False" 
  50.                             ReadOnly="True" 
  51.                             SortExpression="Dealership_Id"
  52.                             HeaderStyle-Width="3%" 
  53.                             ItemStyle-Width="3%" 
  54.                             FooterStyle-Width="3%" >
  55.                         <FooterStyle Width="3%"></FooterStyle>
  56.                         <HeaderStyle Width="3%" HorizontalAlign="Left"></HeaderStyle>
  57.                         <ItemStyle Width="3%"></ItemStyle>
  58.                     </asp:BoundField>
  59.                     <asp:BoundField 
  60.                             DataField="Dealership_Name" 
  61.                             HeaderText="Dealership" 
  62.                             SortExpression="Dealership_Name" 
  63.                             HeaderStyle-Width="18%" 
  64.                             ItemStyle-Width="18%" 
  65.                             FooterStyle-Width="18%">
  66.                         <FooterStyle Width="18%"></FooterStyle>     
  67.                         <HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
  68.                         <ItemStyle Width="18%"></ItemStyle>
  69.                     </asp:BoundField>
  70.                     <asp:BoundField 
  71.                             DataField="Dealership_BranchName" 
  72.                             HeaderText="Branch" 
  73.                             SortExpression="Dealership_BranchName" 
  74.                             HeaderStyle-Width="18%" 
  75.                             ItemStyle-Width="18%" 
  76.                             FooterStyle-Width="18%">
  77.                         <FooterStyle Width="18%"></FooterStyle>
  78.                         <HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
  79.                         <ItemStyle Width="18%"></ItemStyle>
  80.                     </asp:BoundField>
  81.                     <asp:BoundField 
  82.                             DataField="Dealership_Phone1" 
  83.                             HeaderText="Phone" 
  84.                             SortExpression="Dealership_Phone1" 
  85.                             HeaderStyle-Width="9%" 
  86.                             ItemStyle-Width="9%" 
  87.                             FooterStyle-Width="9%" >
  88.                         <FooterStyle Width="9%"></FooterStyle>
  89.                         <HeaderStyle Width="9%" HorizontalAlign="Left"></HeaderStyle>
  90.                         <ItemStyle Width="9%"></ItemStyle>
  91.                     </asp:BoundField>
  92.                     <asp:BoundField 
  93.                             DataField="Dealership_Email1" 
  94.                             HeaderText="Email" 
  95.                             SortExpression="Dealership_Email1" 
  96.                             HeaderStyle-Width="37%" 
  97.                             ItemStyle-Width="37%" 
  98.                             FooterStyle-Width="37%">
  99.                         <FooterStyle Width="37%"></FooterStyle>
  100.                         <HeaderStyle Width="37%" HorizontalAlign="Left"></HeaderStyle>
  101.                         <ItemStyle Width="37%"></ItemStyle>
  102.                     </asp:BoundField>
  103.                     <asp:BoundField 
  104.                             DataField="Dealership_State" 
  105.                             HeaderText="State" 
  106.                             SortExpression="Dealership_State" 
  107.                             HeaderStyle-Width="5%" 
  108.                             ItemStyle-Width="5%" 
  109.                             FooterStyle-Width="5%" >
  110.                         <FooterStyle Width="5%"></FooterStyle>
  111.                         <HeaderStyle Width="5%" HorizontalAlign="Left"></HeaderStyle>
  112.                         <ItemStyle Width="5%"></ItemStyle>
  113.                     </asp:BoundField>
  114.                     <asp:BoundField 
  115.                             DataField="Dealership_ZipCode" 
  116.                             HeaderText="Zip Code" 
  117.                             SortExpression="Dealership_ZipCode" 
  118.                             HeaderStyle-Width="6%" 
  119.                             ItemStyle-Width="6%" 
  120.                             FooterStyle-Width="6%" >
  121.                         <FooterStyle Width="6%"></FooterStyle>
  122.                         <HeaderStyle Width="6%" HorizontalAlign="Left"></HeaderStyle>
  123.                         <ItemStyle Width="6%"></ItemStyle>
  124.                     </asp:BoundField>
  125.                 </Columns>
  126.                     <PagerStyle BackColor="White" ForeColor="Maroon" HorizontalAlign="Right" />
  127.                     <SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333"  />
  128.                     <HeaderStyle BackColor="#AB1414" Font-Bold="True" ForeColor="White" Font-Names="Tahoma" Font-Size="9pt" HorizontalAlign="Left" />
  129.                     <EditRowStyle BackColor="#999999" ForeColor="Black" />
  130.                     <AlternatingRowStyle BackColor="Silver" ForeColor="Black" />
  131.             </asp:GridView>                    
  132.  
  133.    <asp:SqlDataSource ID="DealershipsDS" runat="server" 
  134.  
  135.  
  136.         ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>" 
  137.         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" >
  138.     </asp:SqlDataSource>                                                          
  139.  
  140. </div>
  141. <div>
  142.         <asp:FormView 
  143.             ID="DealershipFormView" 
  144.             runat="server" 
  145.             CellPadding="0" 
  146.             ForeColor="#333333"
  147.             DataKeyNames="Dealership_Id" 
  148.             DataSourceID="DealershipsDetailDS" 
  149.             AllowPaging="true" 
  150.             Width="1024px" 
  151.             BackColor="Black" 
  152.             Font-Names="Tahoma" 
  153.             Font-Size="8pt">
  154.         <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  155.         <RowStyle BackColor="White" />
  156.         <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  157.         <ItemTemplate>
  158.             <table border="0" width="1024px">
  159.                 <tr>
  160.                 <td height="20px" colspan="4" style="padding-top:0px;">&nbsp; </td>
  161.                 </tr>
  162.                 <tr>
  163.                 <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;">Dealership Details</td>
  164.                 </tr>
  165.                 <tr>
  166.                     <td>
  167.                         <table width="800px">
  168.                             <tr>
  169.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  170.                             </tr>
  171.                             <tr>                   
  172.                                 <td style="padding-top:5px;" width="100px">Dealership ID</td>
  173.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Id")%></td>
  174.                                 <td style="padding-top:5px;" width="100px">Email 1</td>
  175.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Email1")%></td>
  176.                             </tr>
  177.                             <tr>
  178.                                 <td style="padding-top:5px;" width="100px">Dealership</td>
  179.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Name")%></td>
  180.                                 <td style="padding-top:5px;" width="100px">Email 2</td>
  181.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Email2")%></td>
  182.                             </tr>
  183.                             <tr>
  184.                                 <td style="padding-top:5px;" width="100px">Branch Name</td>
  185.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_BranchName")%></td>
  186.                                 <td style="padding-top:5px;" width="100px">Email 3</td>
  187.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Email3")%></td>
  188.                             </tr>
  189.                             <tr>
  190.                                 <td style="padding-top:5px;" width="100px">Phone 1</td>
  191.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Phone1")%></td>
  192.                                 <td style="padding-top:5px;" width="100px">Address</td>
  193.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Address")%></td>
  194.                             </tr>
  195.                             <tr>
  196.                                 <td style="padding-top:5px;" width="100px">Phone 2</td>
  197.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Phone2")%></td>
  198.                                 <td style="padding-top:5px;" width="100px">City</td>
  199.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_City")%></td>
  200.                             </tr>
  201.                             <tr>
  202.                                 <td style="padding-top:5px;" width="100px">Phone 3</td>
  203.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Phone3")%></td>
  204.                                 <td style="padding-top:5px;" width="100px">State</td>
  205.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_State")%></td>
  206.                             </tr>
  207.                             <tr>
  208.                                 <td style="padding-top:5px;" width="100px">Fax</td>
  209.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Fax")%></td>
  210.                                 <td style="padding-top:5px;" width="100px">Zip Code</td>
  211.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_ZipCode")%></td>
  212.                             </tr>
  213.                             <tr>
  214.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  215.                             </tr>
  216.                         </tr>
  217.                     </table>
  218.                 </td>
  219.  
  220.             <tr>
  221.                  <td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;">&nbsp;</td>              
  222.             </tr>
  223.             <tr>
  224.                  <td colspan="4" style="padding-top:5px;height:15px;">&nbsp;</td>               
  225.             </tr>
  226.  
  227.             <tr>
  228.                 <td colspan="2" style="padding-top:5px;">
  229.                     <asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" Font-Names="Tahoma" Font-Size="10px" />
  230.                     <asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" Font-Names="tahoma" Font-Size="10px" />
  231.                     <asp:Button ID="btnDelete" runat="Server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" Font-Size="10px" Font-Names="tahoma" />
  232.                 </td>
  233.             </tr>
  234.         </table>
  235.      </ItemTemplate>
  236.  
  237.         <EditItemTemplate>
  238.             <table border="0" width="1024px" style="padding-top:0px;">
  239.                 <tr>
  240.                     <td height="20px" colspan="4" style="padding-top:0px;">&nbsp; </td>
  241.                 </tr>
  242.                 <tr>
  243.                 <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;">Dealership Details</td>
  244.                 </tr>
  245.                 <tr>
  246.                     <td>
  247.                         <table width="800px">
  248.                             <tr>
  249.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  250.                             </tr>
  251.                             <tr>                   
  252.                                 <td style="padding-top:5px;" width="100px">Dealership ID</td>
  253.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Id")%></td>
  254.                                 <td style="padding-top:5px;" width="100px">Email 1</td>
  255.                                 <td style="padding-top:5px;" width="300px">
  256.                                     <asp:TextBox ID="TextBox1" runat="Server" Text='<%# Bind("Dealership_Email1")%>'>
  257.                                     </asp:TextBox>
  258.                                 </td>
  259.                             </tr>
  260.                             <tr>
  261.                                 <td style="padding-top:5px;" width="100px">Dealership</td>
  262.                                 <td style="padding-top:5px;" width="300px">
  263.                                     <asp:TextBox ID="TextBox2" runat="Server" Text='<%# Bind("Dealership_Name")%>'>
  264.                                     </asp:TextBox></td>
  265.                                 <td style="padding-top:5px;" width="100px">Email 2</td>
  266.                                 <td style="padding-top:5px;" width="300px">
  267.                                     <asp:TextBox ID="TextBox3" runat="Server" Text='<%# Bind("Dealership_Email2")%>'>
  268.                                     </asp:TextBox>
  269.                                 </td>
  270.                             </tr>
  271.                             <tr>
  272.                                 <td style="padding-top:5px;" width="100px">Branch Name</td>
  273.                                 <td style="padding-top:5px;" width="300px">
  274.                                     <asp:TextBox  ID="TextBox4" runat="Server" Text='<%# Bind("Dealership_BranchName")%>'>
  275.                                     </asp:TextBox>
  276.                                 </td>
  277.                                 <td style="padding-top:5px;" width="100px">Email 3</td>
  278.                                 <td style="padding-top:5px;" width="300px">
  279.                                     <asp:TextBox ID="TextBox5"  runat="Server" Text='<%# Bind("Dealership_Email3")%>'>
  280.                                     </asp:TextBox>
  281.                                 </td>
  282.                             </tr>
  283.                             <tr>
  284.                                 <td style="padding-top:5px;" width="100px">Phone 1</td>
  285.                                 <td style="padding-top:5px;" width="300px">
  286.                                     <asp:TextBox ID="TextBox6" runat="Server" Text='<%# Bind("Dealership_Phone1")%>'>
  287.                                     </asp:TextBox>
  288.                                 </td>
  289.                                 <td style="padding-top:5px;" width="100px">Address</td>
  290.                                 <td style="padding-top:5px;" width="300px">
  291.                                     <asp:TextBox ID="TextBox7" runat="Server" Text='<%# Bind("Dealership_Address")%>'>
  292.                                     </asp:TextBox>
  293.                                 </td>
  294.                             </tr>
  295.                             <tr>
  296.                                 <td style="padding-top:5px;" width="100px">Phone 2</td>
  297.                                 <td style="padding-top:5px;" width="300px">
  298.                                     <asp:TextBox ID="TextBox8" runat="Server" Text='<%# Bind("Dealership_Phone2")%>'>
  299.                                     </asp:TextBox>
  300.                                 </td>
  301.                                 <td style="padding-top:5px;" width="100px">City</td>
  302.                                 <td style="padding-top:5px;" width="300px">
  303.                                     <asp:TextBox ID="TextBox9" runat="Server" Text='<%# Bind("Dealership_City")%>'>
  304.                                     </asp:TextBox>
  305.                                 </td>
  306.                             </tr>
  307.                             <tr>
  308.                                 <td style="padding-top:5px;" width="100px">Phone 3</td>
  309.                                 <td style="padding-top:5px;" width="300px">
  310.                                     <asp:TextBox ID="TextBox10" runat="Server" Text='<%# Bind("Dealership_Phone3")%>'>
  311.                                     </asp:TextBox>
  312.                                 </td>
  313.                                 <td style="padding-top:5px;" width="100px">State</td>
  314.                                 <td style="padding-top:5px;" width="300px">
  315.                                     <asp:DropDownList ID="myDropDownList" runat="server"   
  316.                                         AppendDataBoundItems="True"  
  317.                                         DataSourceID="StatesDS"   
  318.                                         DataValueField="Dealership_State" 
  319.                                         DataTextField="name"  
  320.                                         SelectedValue='<%#Bind("Dealership_State") %>'>  
  321.                                         <asp:ListItem Value="">Select a State...
  322.                                         </asp:ListItem>  
  323.                                     </asp:DropDownList>  
  324.                                     <asp:XmlDataSource ID="StatesDS" runat="server" DataFile="~/Ddl/States.xml">
  325.                                     </asp:XmlDataSource>                         
  326.                                 </td>
  327.                             </tr>
  328.                             <tr>
  329.                                 <td style="padding-top:5px;" width="100px">Fax</td>
  330.                                 <td style="padding-top:5px;" width="300px">
  331.                                     <asp:TextBox ID="TextBox12" runat="Server" Text='<%# Bind("Dealership_Fax")%>'>
  332.                                     </asp:TextBox>
  333.                                 </td>
  334.                                 <td style="padding-top:5px;" width="100px">Zip Code</td>
  335.                                 <td style="padding-top:5px;" width="300px">
  336.                                     <asp:TextBox ID="TextBox13" runat="Server" Text='<%# Bind("Dealership_ZipCode")%>'>
  337.                                     </asp:TextBox>
  338.                                 </td>
  339.                             </tr>
  340.                             <tr>
  341.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  342.                             </tr>                        
  343.                         </tr>
  344.                     </table>
  345.                 </td>
  346.  
  347.             <tr>
  348.                  <td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;">&nbsp;</td>               
  349.             </tr>
  350.             <tr>
  351.                  <td colspan="4" style="padding-top:5px;height:15px;">&nbsp;</td>                
  352.             </tr>
  353.              <asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1" ErrorMessage="Email 1 is Required" Text="Enter Correct Information.">
  354.                 </asp:RequiredFieldValidator>
  355.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="TextBox2" ErrorMessage="Dealership is Required" Text="Enter Correct Information.">
  356.                 </asp:RequiredFieldValidator>
  357.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="TextBox6" ErrorMessage="Phone 1 is Required" Text="Enter Correct Information.">
  358.                 </asp:RequiredFieldValidator>
  359.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="TextBox7" ErrorMessage="Address is Required" Text="Enter Correct Information.">
  360.                 </asp:RequiredFieldValidator>
  361.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="TextBox9" ErrorMessage="City is Required" Text="Enter Correct Information.">
  362.                 </asp:RequiredFieldValidator>
  363.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="Server" ControlToValidate="TextBox13" ErrorMessage="Zip Code is Required" Text="Enter Correct Information.">
  364.                 </asp:RequiredFieldValidator>
  365.                  <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="Server" ControlToValidate="TextBox4" ErrorMessage="Branch/Location is Required" Text="Enter Correct Information.">
  366.                 </asp:RequiredFieldValidator>
  367.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="Server" ControlToValidate="myDropDownList" ErrorMessage="State is Required" Text="Enter Correct Information.">
  368.                 </asp:RequiredFieldValidator>
  369.             <tr>
  370.                 <td colspan="2" style="padding-top:5px;">            
  371.                         <asp:Button ID="btnUpdate" runat="Server" CommandName="Update" Text="Update" Font-Names="tahoma" Font-Size="10px" />
  372.                         <asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" />
  373.                 </td>
  374.             </tr>
  375.             <asp:ValidationSummary ID="ValidationSummary" runat="Server" ShowMessageBox="true" />
  376.         </table>
  377.  
  378.      </EditItemTemplate>     
  379.  
  380.  <InsertItemTemplate>
  381.              <table border="0" width="1024px" style="padding-top:0px;">
  382.                 <tr>
  383.                     <td height="20px" colspan="4" style="padding-top:0px;">&nbsp; </td>
  384.                 </tr>
  385.                 <tr>
  386.                 <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;">Dealership Details</td>
  387.                 </tr>
  388.                 <tr>
  389.                     <td>
  390.                         <table width="800px">
  391.                             <tr>
  392.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  393.                             </tr>                        
  394.                             <tr>                   
  395.                                 <td style="padding-top:5px;" width="100px">Dealership ID</td>
  396.                                 <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Id")%></td>
  397.                                 <td style="padding-top:5px;" width="100px">Email 1</td>
  398.                                 <td style="padding-top:5px;" width="300px">
  399.                                     <asp:TextBox ID="TextBox1" runat="Server" Text='<%# Bind("Dealership_Email1")%>'>
  400.                                     </asp:TextBox>
  401.                                 </td>
  402.                             </tr>
  403.                             <tr>
  404.                                 <td style="padding-top:5px;" width="100px">Dealership</td>
  405.                                 <td style="padding-top:5px;" width="300px">
  406.                                     <asp:TextBox ID="TextBox2" runat="Server" Text='<%# Bind("Dealership_Name")%>'>
  407.                                     </asp:TextBox></td>
  408.                                 <td style="padding-top:5px;" width="100px">Email 2</td>
  409.                                 <td style="padding-top:5px;" width="300px">
  410.                                     <asp:TextBox ID="TextBox3" runat="Server" Text='<%# Bind("Dealership_Email2")%>'>
  411.                                     </asp:TextBox>
  412.                                 </td>
  413.                             </tr>
  414.                             <tr>
  415.                                 <td style="padding-top:5px;" width="100px">Branch Name</td>
  416.                                 <td style="padding-top:5px;" width="300px">
  417.                                     <asp:TextBox ID="TextBox4" runat="Server" Text='<%# Bind("Dealership_BranchName")%>'>
  418.                                     </asp:TextBox>
  419.                                 </td>
  420.                                 <td style="padding-top:5px;" width="100px">Email 3</td>
  421.                                 <td style="padding-top:5px;" width="300px">
  422.                                     <asp:TextBox ID="TextBox5" runat="Server" Text='<%# Bind("Dealership_Email3")%>'>
  423.                                     </asp:TextBox>
  424.                                 </td>
  425.                             </tr>
  426.                             <tr>
  427.                                 <td style="padding-top:5px;" width="100px">Phone 1</td>
  428.                                 <td style="padding-top:5px;" width="300px">
  429.                                     <asp:TextBox ID="TextBox6" runat="Server" Text='<%# Bind("Dealership_Phone1")%>'>
  430.                                     </asp:TextBox>
  431.                                 </td>
  432.                                 <td style="padding-top:5px;" width="100px">Address</td>
  433.                                 <td style="padding-top:5px;" width="300px">
  434.                                     <asp:TextBox ID="TextBox7" runat="Server" Text='<%# Bind("Dealership_Address")%>'>
  435.                                     </asp:TextBox>
  436.                                 </td>
  437.                             </tr>
  438.                             <tr>
  439.                                 <td style="padding-top:5px;" width="100px">Phone 2</td>
  440.                                 <td style="padding-top:5px;" width="300px">
  441.                                     <asp:TextBox ID="TextBox8" runat="Server" Text='<%# Bind("Dealership_Phone2")%>'>
  442.                                     </asp:TextBox>
  443.                                 </td>
  444.                                 <td style="padding-top:5px;" width="100px">City</td>
  445.                                 <td style="padding-top:5px;" width="300px">
  446.                                     <asp:TextBox ID="TextBox9" runat="Server" Text='<%# Bind("Dealership_City")%>'>
  447.                                     </asp:TextBox>
  448.                                 </td>
  449.                             </tr>
  450.                             <tr>
  451.                                 <td style="padding-top:5px;" width="100px">Phone 3</td>
  452.                                 <td style="padding-top:5px;" width="300px">
  453.                                     <asp:TextBox ID="TextBox10" runat="Server" Text='<%# Bind("Dealership_Phone3")%>'>
  454.                                     </asp:TextBox>
  455.                                 </td>
  456.                                 <td style="padding-top:5px;" width="100px">State</td>
  457.                                 <td style="padding-top:5px;" width="300px">
  458.                                     <asp:DropDownList ID="myDropDownList" runat="server"   
  459.                                         AppendDataBoundItems="True"  
  460.                                         DataSourceID="StatesDS"   
  461.                                         DataValueField="Dealership_State" 
  462.                                         DataTextField="name"  
  463.                                         SelectedValue='<%#Bind("Dealership_State") %>'>  
  464.                                         <asp:ListItem Value="">Select a State...
  465.                                         </asp:ListItem>  
  466.                                     </asp:DropDownList>  
  467.                                     <asp:XmlDataSource ID="StatesDS" runat="server" DataFile="~/Ddl/States.xml">
  468.                                     </asp:XmlDataSource>                         
  469.                                 </td>
  470.                             </tr>
  471.                             <tr>
  472.                                 <td style="padding-top:5px;" width="100px">Fax</td>
  473.                                 <td style="padding-top:5px;" width="300px">
  474.                                     <asp:TextBox ID="TextBox12" runat="Server" Text='<%# Bind("Dealership_Fax")%>'>
  475.                                     </asp:TextBox>
  476.                                 </td>
  477.                                 <td style="padding-top:5px;" width="100px">Zip Code</td>
  478.                                 <td style="padding-top:5px;" width="300px">
  479.                                     <asp:TextBox ID="TextBox13" runat="Server" Text='<%# Bind("Dealership_ZipCode")%>'>
  480.                                     </asp:TextBox>
  481.                                 </td>
  482.                             </tr>
  483.                             <tr>
  484.                                 <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
  485.                             </tr>                            
  486.                         </tr>
  487.                     </table>
  488.                 </td>
  489.  
  490.             <tr>
  491.                  <td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;">&nbsp;</td>               
  492.             </tr>
  493.             <tr>
  494.                  <td colspan="4" style="padding-top:5px;height:15px;">&nbsp;</td>                
  495.             </tr>
  496.              <asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1" ErrorMessage="Email 1 is Required" Text="Enter Correct Information.">
  497.                 </asp:RequiredFieldValidator>
  498.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="TextBox2" ErrorMessage="Dealership is Required" Text="Enter Correct Information.">
  499.                 </asp:RequiredFieldValidator>
  500.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="TextBox6" ErrorMessage="Phone 1 is Required" Text="Enter Correct Information.">
  501.                 </asp:RequiredFieldValidator>
  502.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="TextBox7" ErrorMessage="Address is Required" Text="Enter Correct Information.">
  503.                 </asp:RequiredFieldValidator>
  504.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="TextBox9" ErrorMessage="City is Required" Text="Enter Correct Information.">
  505.                 </asp:RequiredFieldValidator>
  506.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="Server" ControlToValidate="TextBox13" ErrorMessage="Zip Code is Required" Text="Enter Correct Information.">
  507.                 </asp:RequiredFieldValidator>
  508.                  <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="Server" ControlToValidate="TextBox4" ErrorMessage="Branch/Location is Required" Text="Enter Correct Information.">
  509.                 </asp:RequiredFieldValidator>
  510.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="Server" ControlToValidate="myDropDownList" ErrorMessage="State is Required" Text="Enter Correct Information.">
  511.                 </asp:RequiredFieldValidator>
  512.  
  513.  
  514.             <tr>
  515.                 <td colspan="2" style="padding-top:5px;">
  516.                      <asp:Button ID="btnSave" runat="Server" CommandName="insert" Text="Insert" Font-Names="tahoma" Font-Size="10px" />
  517.                         <asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" />
  518.  
  519.  
  520.                 </td>
  521.             </tr>
  522.         <asp:ValidationSummary ID="ValidationSummary" runat="Server" ShowMessageBox="true" />
  523.         </table>
  524.      </InsertItemTemplate>   
  525.  
  526.  
  527.     </asp:FormView>
  528. <asp:SqlDataSource ID="DealershipsDetailDS" runat="server" 
  529.         ConnectionString="<%$ ConnectionStrings:drivetime %>" 
  530.  
  531.         SelectCommand="SELECT [Dealership_Id], [Dealership_Name], [Dealership_BranchName], [Dealership_Phone1], [Dealership_Phone2], [Dealership_Phone3], [Dealership_Fax], [Dealership_Email1], [Dealership_Email2], [Dealership_Email3], [Dealership_Address], [Dealership_City], [Dealership_State], [Dealership_ZipCode] FROM [CAR_Dealership] WHERE ([Dealership_Id] = @Dealership_Id)" 
  532.         ConflictDetection="CompareAllValues" 
  533.         DeleteCommand="DELETE FROM [CAR_Dealership] WHERE [Dealership_Id] = @original_Dealership_Id AND [Dealership_Name] = @original_Dealership_Name AND [Dealership_BranchName] = @original_Dealership_BranchName AND [Dealership_Phone1] = @original_Dealership_Phone1 AND [Dealership_Phone2] = @original_Dealership_Phone2 AND [Dealership_Phone3] = @original_Dealership_Phone3 AND [Dealership_Fax] = @original_Dealership_Fax AND [Dealership_Email1] = @original_Dealership_Email1 AND [Dealership_Email2] = @original_Dealership_Email2 AND [Dealership_Email3] = @original_Dealership_Email3 AND [Dealership_Address] = @original_Dealership_Address AND [Dealership_City] = @original_Dealership_City AND [Dealership_State] = @original_Dealership_State AND [Dealership_ZipCode] = @original_Dealership_ZipCode" 
  534.         InsertCommand="INSERT INTO [CAR_Dealership] ([Dealership_Name], [Dealership_BranchName], [Dealership_Phone1], [Dealership_Phone2], [Dealership_Phone3], [Dealership_Fax], [Dealership_Email1], [Dealership_Email2], [Dealership_Email3], [Dealership_Address], [Dealership_City], [Dealership_State], [Dealership_ZipCode]) VALUES (@Dealership_Name, @Dealership_BranchName, @Dealership_Phone1, @Dealership_Phone2, @Dealership_Phone3, @Dealership_Fax, @Dealership_Email1, @Dealership_Email2, @Dealership_Email3, @Dealership_Address, @Dealership_City, @Dealership_State, @Dealership_ZipCode)" 
  535.         OldValuesParameterFormatString="original_{0}"      
  536.         UpdateCommand="UPDATE [CAR_Dealership] SET [Dealership_Name] = @Dealership_Name, [Dealership_BranchName] = @Dealership_BranchName, [Dealership_Phone1] = @Dealership_Phone1, [Dealership_Phone2] = @Dealership_Phone2, [Dealership_Phone3] = @Dealership_Phone3, [Dealership_Fax] = @Dealership_Fax, [Dealership_Email1] = @Dealership_Email1, [Dealership_Email2] = @Dealership_Email2, [Dealership_Email3] = @Dealership_Email3, [Dealership_Address] = @Dealership_Address, [Dealership_City] = @Dealership_City, [Dealership_State] = @Dealership_State, [Dealership_ZipCode] = @Dealership_ZipCode WHERE [Dealership_Id] = @original_Dealership_Id AND [Dealership_Name] = @original_Dealership_Name AND [Dealership_BranchName] = @original_Dealership_BranchName AND [Dealership_Phone1] = @original_Dealership_Phone1 AND [Dealership_Phone2] = @original_Dealership_Phone2 AND [Dealership_Phone3] = @original_Dealership_Phone3 AND [Dealership_Fax] = @original_Dealership_Fax AND [Dealership_Email1] = @original_Dealership_Email1 AND [Dealership_Email2] = @original_Dealership_Email2 AND [Dealership_Email3] = @original_Dealership_Email3 AND [Dealership_Address] = @original_Dealership_Address AND [Dealership_City] = @original_Dealership_City AND [Dealership_State] = @original_Dealership_State AND [Dealership_ZipCode] = @original_Dealership_ZipCode">
  537.     <SelectParameters>
  538.         <asp:ControlParameter ControlID="DealershipGrid" Name="Dealership_Id" 
  539.             PropertyName="SelectedValue" Type="Int32" />
  540.     </SelectParameters>
  541.     <DeleteParameters>
  542.         <asp:Parameter Name="original_Dealership_Id" Type="Int32" />
  543.         <asp:Parameter Name="original_Dealership_Name" Type="String" />
  544.         <asp:Parameter Name="original_Dealership_BranchName" Type="String" />
  545.         <asp:Parameter Name="original_Dealership_Phone1" Type="String" />
  546.         <asp:Parameter Name="original_Dealership_Phone2" Type="String" />
  547.         <asp:Parameter Name="original_Dealership_Phone3" Type="String" />
  548.         <asp:Parameter Name="original_Dealership_Fax" Type="String" />
  549.         <asp:Parameter Name="original_Dealership_Email1" Type="String" />
  550.         <asp:Parameter Name="original_Dealership_Email2" Type="String" />
  551.         <asp:Parameter Name="original_Dealership_Email3" Type="String" />
  552.         <asp:Parameter Name="original_Dealership_Address" Type="String" />
  553.         <asp:Parameter Name="original_Dealership_City" Type="String" />
  554.         <asp:Parameter Name="original_Dealership_State" Type="String" />
  555.         <asp:Parameter Name="original_Dealership_ZipCode" Type="String" />
  556.     </DeleteParameters>
  557.     <UpdateParameters>
  558.         <asp:Parameter Name="Dealership_Name" Type="String" />
  559.         <asp:Parameter Name="Dealership_BranchName" Type="String" />
  560.         <asp:Parameter Name="Dealership_Phone1" Type="String" />
  561.         <asp:Parameter Name="Dealership_Phone2" Type="String" />
  562.         <asp:Parameter Name="Dealership_Phone3" Type="String" />
  563.         <asp:Parameter Name="Dealership_Fax" Type="String" />
  564.         <asp:Parameter Name="Dealership_Email1" Type="String" />
  565.         <asp:Parameter Name="Dealership_Email2" Type="String" />
  566.         <asp:Parameter Name="Dealership_Email3" Type="String" />
  567.         <asp:Parameter Name="Dealership_Address" Type="String" />
  568.         <asp:Parameter Name="Dealership_City" Type="String" />
  569.         <asp:Parameter Name="Dealership_State" Type="String" />
  570.         <asp:Parameter Name="Dealership_ZipCode" Type="String" />
  571.         <asp:Parameter Name="original_Dealership_Id" Type="Int32" />
  572.         <asp:Parameter Name="original_Dealership_Name" Type="String" />
  573.         <asp:Parameter Name="original_Dealership_BranchName" Type="String" />
  574.         <asp:Parameter Name="original_Dealership_Phone1" Type="String" />
  575.         <asp:Parameter Name="original_Dealership_Phone2" Type="String" />
  576.         <asp:Parameter Name="original_Dealership_Phone3" Type="String" />
  577.         <asp:Parameter Name="original_Dealership_Fax" Type="String" />
  578.         <asp:Parameter Name="original_Dealership_Email1" Type="String" />
  579.         <asp:Parameter Name="original_Dealership_Email2" Type="String" />
  580.         <asp:Parameter Name="original_Dealership_Email3" Type="String" />
  581.         <asp:Parameter Name="original_Dealership_Address" Type="String" />
  582.         <asp:Parameter Name="original_Dealership_City" Type="String" />
  583.         <asp:Parameter Name="original_Dealership_State" Type="String" />
  584.         <asp:Parameter Name="original_Dealership_ZipCode" Type="String" />
  585.     </UpdateParameters>
  586.     <InsertParameters>
  587.         <asp:Parameter Name="Dealership_Name" Type="String" />
  588.         <asp:Parameter Name="Dealership_BranchName" Type="String" />
  589.         <asp:Parameter Name="Dealership_Phone1" Type="String" />
  590.         <asp:Parameter Name="Dealership_Phone2" Type="String" />
  591.         <asp:Parameter Name="Dealership_Phone3" Type="String" />
  592.         <asp:Parameter Name="Dealership_Fax" Type="String" />
  593.         <asp:Parameter Name="Dealership_Email1" Type="String" />
  594.         <asp:Parameter Name="Dealership_Email2" Type="String" />
  595.         <asp:Parameter Name="Dealership_Email3" Type="String" />
  596.         <asp:Parameter Name="Dealership_Address" Type="String" />
  597.         <asp:Parameter Name="Dealership_City" Type="String" />
  598.         <asp:Parameter Name="Dealership_State" Type="String" />
  599.         <asp:Parameter Name="Dealership_ZipCode" Type="String" />
  600.     </InsertParameters>
  601.     </asp:SqlDataSource>
  602.  
  603. </div>             
  604.  
  605. </asp:Content>

...
Jan 12 '10 #1
4 2864
Frinavale
9,735 Expert Mod 8TB
Hi J,

In the future could you please only post the code that pertains to your question. That is a lot of code to ask people to look over. Also, in the future, please post your code in code tags.

Anyways, I've never used a FormView before and I don't have much experience with the SqlDataSource; however, it sounds like you've designed your database in such a way that nulls aren't allowed. In this case you must provide a value for the fields that cannot be set to null or you have to change your database to allow nulls to be entered (but in a lot of cases it doesn't make sense to do this because the database design requires it)

So, I recommend using things like the Validator controls to make sure that the user has entered something. You could also consider setting default values to help the user along.

-Frinny
Jan 12 '10 #2
Frinny,

I will do all of the above. Thanks or your response. Nulls are allowed the db. How do you set default values for textboxes that also have bind.



Thanks,

J

Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox class="aclDetTxt" ID="TextBox9" runat="Server" Text='<%# Bind("Dealership_City")%>'>
  2.                                     </asp:TextBox> 
Jan 12 '10 #3
mzmishra
390 Expert 256MB
This article may help you
http:// forums.asp.net/t/1064910.aspx
Jan 14 '10 #4
Frinavale
9,735 Expert Mod 8TB
Ahh, I think you'd be interested in looking at creating an EmptyDataTemplate for rows that contain not data.

-Frinny
Jan 25 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
0
by: H5N1 | last post by:
hi all it's extremely common scenario, so I would like to ask you how do you usually implement CRUD functionality for following structure. Basically it's all about displaying "foreign name" (ie....
1
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.