Dear All,
I am trying to update values in the GridView but have some issue with the Datetime (which I want to keep Readonly)
On updating the GridView, I am getting the following error:
 ERROR: "System.FormatException: Input string was not in a correct format."
How to fix the below is the code?
 Database COLUMN:
BestillingDato, nVarchar(50), Allow Nulls
HTML Form:
      
<asp:TextBox ID="txtBestillingDato" runat="server" Width="260px"></asp:TextBox>
GRIDVIEW Table:                  
  
<asp:TemplateField HeaderText="Bestilling Dato">
            <ItemTemplate>
                        <asp:Label ID="lblBestillingDato" runat="server" Text='<%# Bind("BestillingDato","{0:d}") %>'></asp:Label>
             </ItemTemplate>
             <EditItemTemplate>
                            <asp:TextBox ID="txtBestillingDato" runat="Server" Columns="20" Text='<%# Bind("BestillingDato","{0:d}")%>' ReadOnly="true"></asp:TextBox>
             </EditItemTemplate>
</asp:TemplateField>
  ----------------------------------------------------------                       
 CODEBEHIND:
            if (!IsPostBack)
            {
              // Get the date on the TextBox form as: 21/12/2013
               txtBestillingDato.Text = DateTime.Now.ToString("dd/MM/yyyy");
                txtBestillingDato.ReadOnly = true;
             }
 
protected void GridView1_UpdateRecord(object sender, GridViewUpdateEventArgs e)
{
.....
 TextBox tBestillingDato = (TextBox)row.FindControl("txtBestillingDato");
 
dCmd.Parameters.Add("@BestillingDato", SqlDbType.NVarChar, 50).Value = tBestillingDato.Text.Trim();
..... 
}
 -------------------------------------------------------------
 
Many thanks in advance