Ext.NET error: System.Exception: String was not recognized as a valid DateTime

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Ext.NET error: System.Exception: String was not recognized as a valid DateTime

    i have a date colum like this
    <ext:DateColumn ID="DateColumn4" runat="server" DataIndex="Purchasedate" Text="Purchasedate"  Format="yyyy-MM-dd" Flex="1" />
    when it is clicked ,it shows detail data inside a form.

    using the sqldatasource,i am able to insert,update,create ,except of the datecolum.

    whenever ,i try to insert data(in this example ,it is a datecolum) ,it is inserted into sqldatabase as NULL value. when i insert a date in sqldatabase manually,and read the data from gridpanel,it seems no problem.it shows all data correctly. But,when i try to update date on the form ,it gives me a error somethink like this:

    {serviceResponse:{success:false,message:"System.Exception: String was not recognized as a valid DateTime. ---> System.FormatException: String was not recognized as a valid DateTime.\r\n at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)\r\n at System.Convert.ToDateTime(String value, IFormatProvider provider)\r\n at System.String.System.IConvertible.ToDateTime(IFormatProvider provider)\r\n at System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider)\r\n at System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges)\r\n at System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges)\r\n at System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, String oldValuesParameterFormatString)\r\n at System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)\r\n at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback)\r\n at Ext.Net.Store.MakeUpdates(IDataSource ds, JArray data) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 890\r\n at Ext.Net.Store.MakeChanges() in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 829\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 793\r\n --- End of inner exception stack trace ---\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 806\r\n at Ext.Net.Store.RaiseAjaxPostBackEvent(String eventArgument) in C:\\Users\\Geoffrey McGill\\Documents\\Visual Studio 2010\\Projects\\Ext.NET\\v2\\Ext.Net\\Ext\\Data\\Store.cs:line 1131",data:}}



    for example when updating date something like this 2012-12-15 ,it gives the error like above ,however when i try to update date something like this 2012-12-11(a value that doesnt pass the 12,it seems work fine) ,it doesnt give a error at all.

    is there a bug related to "date format" in EXT.NET ??

    thank you.
  2. #2
    Can you demonstrate the issue with simple example?
  3. #3
    Hi,

    Try setting DateFormat="ms" in your <ext:ModelField> config. Something similar to the following:

    Example

    <ext:ModelField Name="Purchasedate" Type="Date" DateFormat="ms" />
    Or, if you have already set the .DateFormat property with something, try removing that property completely.

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

    Try setting DateFormat="ms" in your <ext:ModelField> config. Something similar to the following:

    Example

    <ext:ModelField Name="Purchasedate" Type="Date" DateFormat="ms" />
    Or, if you have already set the .DateFormat property with something, try removing that property completely.

    Hope this helps.
    Hi Geoffrey McGill ;

    both way dont seems work.i still get same error.
  5. #5
    Quote Originally Posted by ada View Post
    Hi Geoffrey McGill ;

    both way dont seems work.i still get same error.
    What about this request from Vladimir?

    Can you demonstrate the issue with simple example?
    Geoffrey McGill
    Founder
  6. #6
    Quote Originally Posted by geoffrey.mcgill View Post
    What about this request from Vladimir?
    all are in the same webform application called Dlist.aspx

    //my sqldatasource
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AConnectionString %>"
            SelectCommand="SELECT * FROM Dem" DeleteCommand="DELETE  FROM  Dem WHERE (Id = @Id)"
            InsertCommand="INSERT INTO Dem
               (.....
    		   ......)
         VALUES
               (......
    		   ......
               );
               SELECT @NewId = @@Identity; 
               "
               UpdateCommand="UPDATE Dem SET 
                                    .......
    								.......
                                    AlisTrh = @AlisTrh, 
    								.......
    								.......
    								
                               WHERE (Id = @Id)"
                OnInserted="SqlDataSource1_Inserted">
            <DeleteParameters>
                <asp:Parameter Name="Id" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                .......
    			.......
                <asp:Parameter Name="AlisTrh" Type="DateTime" />
                .......
    			.......
                <asp:Parameter Direction="Output" Name="NewId" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                 <asp:Parameter Name="Ad" Type="String" />
              .......
    		  .......
                <asp:Parameter Name="AlisTrh" Type="DateTime" />
                <asp:Parameter Name="Tutar" Type="String" />
              ........
    		  ........
                <asp:Parameter Name="Id" Type="Int32" />
            
            </UpdateParameters>
        </asp:SqlDataSource>
    
     <ext:FormPanel ID="UserForm" runat="server" Title="De info" Frame="true"
            Padding="3" AutoScroll="true" BodyPadding="0" Flex="1">
    
    		.....
    		.....
    		.....
    		
    // my form field (when click the grid view row ,it shows the data detail in this form panel area)
    ......
    ......
    
          <ext:Container ID="Container2" runat="server" Layout="HBoxLayout" Padding="3">
                                                    <Items>
                                                        <ext:TextField ID="Cins" runat="server" FieldLabel="dem cins" Flex="1">
                                                        </ext:TextField>
                                                        <ext:DateField ID="AlisTrh" Format="dd/MM/yyyy" runat="server" FieldLabel="Alış Trh" Type="Date"
                                                            Flex="1" />
                                                    </Items>
                                                </ext:Container>
    											
    ........
    ........
    
        <ext:ButtonGroup ID="ButtonGroup1" runat="server" Flex="1">
                                    <Buttons>
                                        <ext:Button ID="Button1" runat="server" Text="save" Icon="Disk">
                                            <Listeners>
                                                <Click Handler="updateRecord(#{UserForm});" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="Button2" runat="server" Text="add new item" Icon="UserAdd">
                                            <Listeners>
                                                <Click Handler="addRecord(#{UserForm}, #{dgrid});" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="Button3" runat="server" Text="clean form">
                                            <Listeners>
                                                <Click Handler="#{UserForm}.getForm().reset();" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="btnDelete" runat="server" Text="delet selected row" Icon="Delete">
                                            <Listeners>
                                                <Click Handler="#{dgrid}.deleteSelected();#{UserForm}.getForm().reset();" />
                                            </Listeners>
                                        </ext:Button>
                                    </Buttons>
                                </ext:ButtonGroup>
    
    
    
    
    
    //my model and gridview
    
    <ext:GridPanel ID="dgrid" runat="server" Title="DL" AutoScroll="true" Height="300"
                                    Flex="1">
                                    <Store>
                                        <ext:Store ID="Store1" runat="server" DataSourceID="SqlDataSource1" AutoSync="true"
                                                    ShowWarningOnFailure="true"
                                                    OnAfterRecordInserted="Store1_AfterRecordInserted" 
                                                    OnReadData="Store1_RefershData">
                                            <Model>
                                                <ext:Model ID="Model1" runat="server" IDProperty="Id" Name="DModel">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" />
                                                        .......
    													.......
                                                        <ext:ModelField Name="AlisTrh" Type="Date"  /> 
                                                       // i tried to use DateFormat="ms"  but didnt work
                                                        .......
    													.......
                                                        <ext:ModelField Name="something" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                            <Listeners>
                                                <Exception Handler="Ext.Msg.alert('Operation failed', operation.getError());" />
                                                <Write Handler="Ext.Msg.alert('', 'veriler kaydedildi');" />
                                            </Listeners>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel ID="ColumnModel1" runat="server" Flex="1">
                                        <Columns>
                                            <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="35" AutoDataBind="true" />
                                        ..........
    									..........
                                            <ext:DateColumn ID="DateColumn4" runat="server" DataIndex="Purchasedate" Text="AT" Format="dd/MM/yyyy" Flex="1" />
                                        </Columns>
                                    </ColumnModel>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single">
                                            <Listeners>
                                                <Select Handler="#{UserForm}.getForm().loadRecord(record);" />
                                            </Listeners>
                                        </ext:RowSelectionModel>
                                    </SelectionModel>
                                </ext:GridPanel>
    							
    ........
    ........

    here is th e a screnshot of the error..
    (when updating the date field ,i get this error.in addition to that,when inserting date to sqlserver ,it is inserted as a null value)


    Click image for larger version. 

Name:	error.PNG 
Views:	197 
Size:	75.6 KB 
ID:	5279
    Last edited by ada; Dec 17, 2012 at 7:07 PM.

Similar Threads

  1. Replies: 4
    Last Post: Feb 06, 2012, 9:51 AM
  2. Replies: 4
    Last Post: Feb 01, 2011, 12:54 PM
  3. Replies: 0
    Last Post: Dec 27, 2009, 2:47 PM
  4. Replies: 2
    Last Post: Aug 31, 2009, 7:03 PM
  5. System Security Exception
    By jaydwire2 in forum 1.x Help
    Replies: 0
    Last Post: Jul 31, 2009, 4:38 PM

Tags for this Thread

Posting Permissions