title: Trying to update a ASP.NET(C#) gridview datetime field
body: <p>I have gridview in asp.net connected to a sqldatasource, and I have the edit option checked. I have two fields I want to update, one named <code>CHECKTIME(data type datetime)</code> and <code>CHECKTYPE</code>. I am able to update <code>CHECKTYPE</code> with the gridview with no problems but when I try to update <code>CHECKTIME</code> it doesn't change, but instead it stays with the original values. Please help; below find the update query I'm using.</p>
  
  <p>Query:</p>
  
  <pre><code>UPDATE CHECKINOUT SET CHECKTYPE = @CHECKTYPE, CHECKTIME = @CHECKTIME  
  FROM CHECKINOUT INNER JOIN USERINFO  
  ON CHECKINOUT.USERID = USERINFO.USERID  
  WHERE (CHECKINOUT.USERID = @USERID) AND (CHECKINOUT.trans = @trans)
  </code></pre>
  
  <p>updategridview.aspx</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TimeClockManager.aspx.cs" Inherits="TimeClockViewer.WebForm1" %&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:attConnectionString %&gt;" SelectCommand="SELECT USERINFO.USERID, USERINFO.NAME, USERINFO.TITLE, CHECKINOUT.CHECKTIME, CHECKINOUT.CHECKTYPE FROM USERINFO INNER JOIN CHECKINOUT ON USERINFO.USERID = CHECKINOUT.USERID
  WHERE ( NAME = @NAME and @NAME&amp;lt;&amp;gt; '-1' OR @NAME = '-1' and 1=1) AND CHECKTIME BETWEEN @startDate AND @endDate + ' 23:59:00.000'" UpdateCommand="UPDATE CHECKINOUT SET CHECKTYPE = @CHECKTYPE, CHECKTIME = convert(datetime,@CHECKTIME)
  FROM CHECKINOUT INNER JOIN USERINFO ON CHECKINOUT.USERID = USERINFO.USERID 
  WHERE (CHECKINOUT.USERID = @USERID) AND (CHECKINOUT.trans = @trans)"&gt;
          &lt;SelectParameters&gt;
              &lt;asp:ControlParameter ControlID="ddlEmployee" Name="NAME" PropertyName="SelectedValue" /&gt;
              &lt;asp:ControlParameter ControlID="txtBoxStartDate" Name="startDate" PropertyName="Text" /&gt;
              &lt;asp:ControlParameter ControlID="txtBoxEndDate" Name="endDate" PropertyName="Text" /&gt;
          &lt;/SelectParameters&gt;
          &lt;UpdateParameters&gt;
              &lt;asp:Parameter Name="CHECKTYPE" /&gt;
              &lt;asp:Parameter Name="CHECKTIME"  /&gt;
              &lt;asp:Parameter Name="USERID" /&gt;
              &lt;asp:Parameter Name="trans" /&gt;
          &lt;/UpdateParameters&gt;
      &lt;/asp:SqlDataSource&gt;
  &amp;nbsp;Employee:
      &lt;asp:DropDownList ID="ddlEmployee" runat="server" DataSourceID="SqlDataSource2" DataTextField="NAME" DataValueField="NAME" Height="40px" Width="193px" AppendDataBoundItems="True"&gt;
          &lt;asp:ListItem Value="-1"&gt;All&lt;/asp:ListItem&gt;
  
      &lt;/asp:DropDownList&gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp; Start Date:
  
      &lt;asp:TextBox ID="txtBoxStartDate" runat="server" Width="146px"&gt;&lt;/asp:TextBox&gt;
  
  &amp;nbsp;&amp;nbsp;&amp;nbsp; End Date&lt;ajaxToolkit:CalendarExtender ID="txtBoxStartDate_CalendarExtender" runat="server" Enabled="True" TargetControlID="txtBoxStartDate"&gt;
      &lt;/ajaxToolkit:CalendarExtender&gt;
      :
      &lt;asp:TextBox ID="txtBoxEndDate" runat="server" Width="146px"&gt;&lt;/asp:TextBox&gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
      &lt;ajaxToolkit:CalendarExtender ID="txtBoxEndDate_CalendarExtender" runat="server" Enabled="True" TargetControlID="txtBoxEndDate"&gt;
      &lt;/ajaxToolkit:CalendarExtender&gt;
      &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" /&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="&lt;%$ ConnectionStrings:attConnectionString %&gt;" SelectCommand="SELECT [NAME] FROM [USERINFO] ORDER BY [NAME]"&gt;&lt;/asp:SqlDataSource&gt;
      &lt;br /&gt;
      &lt;asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" DataKeyNames="USERID"&gt;
          &lt;AlternatingRowStyle BackColor="White" /&gt;
          &lt;Columns&gt;
              &lt;asp:CommandField ShowEditButton="True" /&gt;
              &lt;asp:BoundField DataField="USERID" HeaderText="USERID" InsertVisible="False" SortExpression="USERID" ReadOnly="True" /&gt;
              &lt;asp:BoundField DataField="NAME" HeaderText="NAME" SortExpression="NAME" /&gt;
              &lt;asp:BoundField DataField="TITLE" HeaderText="TITLE" SortExpression="TITLE" /&gt;
              &lt;asp:BoundField DataField="CHECKTIME" HeaderText="CHECKTIME" SortExpression="CHECKTIME" /&gt;
              &lt;asp:BoundField DataField="CHECKTYPE" HeaderText="CHECKTYPE" SortExpression="CHECKTYPE" /&gt;
          &lt;/Columns&gt;
          &lt;EditRowStyle BackColor="#7C6F57" /&gt;
          &lt;FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
          &lt;HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
          &lt;PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /&gt;
          &lt;RowStyle BackColor="#E3EAEB" /&gt;
          &lt;SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /&gt;
          &lt;SortedAscendingCellStyle BackColor="#F8FAFA" /&gt;
          &lt;SortedAscendingHeaderStyle BackColor="#246B61" /&gt;
          &lt;SortedDescendingCellStyle BackColor="#D4DFE1" /&gt;
          &lt;SortedDescendingHeaderStyle BackColor="#15524A" /&gt;
      &lt;/asp:GridView&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>