Page 1 of 2 12 LastLast
Results 1 to 10 of 13

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

  1. #1
    Member
    Join Date
    Nov 2012
    Posts
    60

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

    i have a date colum like this
    Code:
    <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:

    Code:
    {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
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,159
    Can you demonstrate the issue with simple example?
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Ext.NET - Dev Team geoffrey.mcgill's Avatar
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8,383
    Hi,

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

    Example

    Code:
    <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
    Ext.NET, Inc.
    Founder, and Dev Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | @extnet | Jobs

  4. #4
    Member
    Join Date
    Nov 2012
    Posts
    60
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

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

    Example

    Code:
    <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
    Ext.NET - Dev Team geoffrey.mcgill's Avatar
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8,383
    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
    Ext.NET, Inc.
    Founder, and Dev Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | @extnet | Jobs

  6. #6
    Member
    Join Date
    Nov 2012
    Posts
    60
    Quote Originally Posted by geoffrey.mcgill View Post
    What about this request from Vladimir?
    all are in the same webform application called Dlist.aspx

    Code:
    //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:	65 
Size:	75.6 KB 
ID:	5279
    Last edited by ada; Dec 17, 2012 at 6:07 PM.

  7. #7
    Member
    Join Date
    Nov 2012
    Posts
    60
    anybody help me??

    Quote Originally Posted by ada View Post
    all are in the same webform application called Dlist.aspx

    Code:
    //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:	65 
Size:	75.6 KB 
ID:	5279

  8. #8
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,159
    It seems that data is submitted with wrong format.
    Do you able to debug Ext.Net code? For example, set breakpoint to Store.MakeUpdates method and investigate how looks submitted date
    I tried to reproduce the issue but date is parsed fine by SqlDataSource on my side
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  9. #9
    Member
    Join Date
    Nov 2012
    Posts
    60
    Quote Originally Posted by Vladimir View Post
    It seems that data is submitted with wrong format.
    Do you able to debug Ext.Net code? For example, set breakpoint to Store.MakeUpdates method and investigate how looks submitted date
    I tried to reproduce the issue but date is parsed fine by SqlDataSource on my side
    hi vladimir,

    when i looked at the source code generated,i found something like this,i guess this cause to problem.

    Code:
    Ext.onReady(function(){Ext.create("Ext.form.Panel",{id:"UserForm",frame:true,padding:3,renderTo:"App.UserForm_Container",flex:1,au 
    .......................
    .......................
    renderTo:"App.UserForm_Container",flex:1,autoScroll:true,items:[{id:"Container11",margin:"0 0 
    ...................
    ...................
    {id:"AlisTrh",xtype:"datefield",flex:1,fieldLabel:"Alis tarihi",format:"d-m-Y",submitFormat:"d.m.Y"}],layout:"hbox"},
    .......................
    .......................
    i try to figure out what going on there ,but i have no clue yet
    Last edited by ada; Dec 21, 2012 at 9:14 AM.

  10. #10
    Ext.NET - Dev Team geoffrey.mcgill's Avatar
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8,383
    When I try to run your code sample an Exception is thrown.

    Please review the following forum posts:

    http://forums.ext.net/showthread.php...ation-Required

    http://forums.ext.net/showthread.php...ing-New-Topics
    Geoffrey McGill
    Ext.NET, Inc.
    Founder, and Dev Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | @extnet | Jobs

Similar Threads

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

Tags for this Thread

Posting Permissions