Search Results

Search found 1 results on 1 pages for 'brabbeldas'.

Page 1/1 | 1 

  • asp.net gridview bind dateformat not working with update

    - by Brabbeldas
    I have a GridView with a TemplateField column which shows a DateTime from a DataSource. <Columns> <asp:CommandField ShowEditButton="True" /> <asp:TemplateField HeaderText="Start Date"> <EditItemTemplate> <asp:TextBox ID="txtDateStart" runat="server" Text='<%# Bind("dtDateStart", "{0:dd/MM/yyyy}") %>'</asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("dtDateStart", "{0:dd/MM/yyyy}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> Displaying the date in the correct format works as it should. Note that the format starts with DAY followed by MONTH. When I switch to edit mode, change the date in the TextBox to '31-01-2013' and press the GridView's update-link i get an error: Cannot convert value of parameter 'dtDateStart' from 'System.String' to 'System.DateTime' The error is generated by the GridView not my own code. It happens before the UpdateMethod of my DataSource is called. When i type '01-31-2012' the data is processed correctly and the value is updated into the database. Somehow when the date is displayed it uses format dd-MM-yyyy (just as I need it to) But when it reads the new value form the TextBox it uses MM-dd-yyyy Can somebody please help me?

    Read the article

1