LinqDataSource with FormView update/insert LinqDataSourceValidationException

Last post 05-07-2008 10:41 AM by dines. 4 replies.

Sort Posts:

  • LinqDataSource with FormView update/insert LinqDataSourceValidationException

    05-01-2008, 1:31 PM
    • Loading...
    • dines
    • Joined on 05-04-2003, 6:04 AM
    • Germany
    • Posts 131

    Hello,

    I try to use a Linq Datasource with a formview control. I set up the linqdatasource to a table and bind it to the formview. Whenever I do an update or insert I get following error.

    My table holds several strings (varchar), int and DateTime values...

     

    Nothing special here, but I can not figure out where the exception comes from

     

    Any help would be great  

    Serverfehler in der Anwendung /...


    Failed to set one or more properties on type Contact.  Ensure that the input values are valid and can be converted to the corresponding property types.

    Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.

    Ausnahmedetails: System.Web.UI.WebControls.LinqDataSourceValidationException: Failed to set one or more properties on type Contact.  Ensure that the input values are valid and can be converted to the corresponding property types.

    Quellfehler:

    Beim Ausführen der aktuellen Webanforderung wurde einen unbehandelte Ausnahme generiert. Informationen über den Ursprung und die Position der Ausnahme können mit der Ausnahmestapelüberwachung angezeigt werden.


    Stapelüberwachung:
     
    [LinqDataSourceValidationException: Failed to set one or more properties on type Contact.  Ensure that the input values are valid and can be converted to the corresponding property types.]
       System.Web.UI.WebControls.LinqDataSourceView.BuildDataObject(Type dataObjectType, IDictionary inputParameters) +528
       System.Web.UI.WebControls.LinqDataSourceView.BuildUpdateDataObjects(Object table, IDictionary keys, IDictionary values, IDictionary oldValues) +244
       System.Web.UI.WebControls.LinqDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +142
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
       System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1150
       System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +440
       System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
      

     

     

  • Re: LinqDataSource with FormView update/insert LinqDataSourceValidationException

    05-05-2008, 11:41 PM
    Answer

    Hi dines,

    From your description, you need to take care of these two things.

    First, ensure the entity value to insert is legal - check whether both the type and length are matching.

    Second, you need to specify DataKeyNames property in your FormView control. In this case, the update will be impacted.

     

    Thanks.

    Sincerely,
    JanIvan Qian

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
  • Re: LinqDataSource with FormView update/insert LinqDataSourceValidationException

    05-06-2008, 3:32 PM
    • Loading...
    • dines
    • Joined on 05-04-2003, 6:04 AM
    • Germany
    • Posts 131

    I could nail the problem down. I think I did I am not sure. What happened was, I changed the table in the database then I deleted the class from my linq-to-sql designer. Refreshed everything and I added the table from Server-Explorer again.

    Everything looks fine but causes this error. It happens only when I work with formview ... The update works with gridview. I did not find the time to test it with other data controls.

    When I delete my linq-to-sql file and create everything from scratch it works... But it seems like the designer from linq-to-sql does not like any changes in the database...

    I tryed this also with Web Developer Express and I had the same issue. Can somebody confirm that?

  • Re: LinqDataSource with FormView update/insert LinqDataSourceValidationException

    05-06-2008, 10:40 PM

    Hi Dines,

    When your table schema in database changes, it will not affect the LINQ-SQL.

    So you need to delete the table in LINQ-SQL designer, refresh Server Explorer and add the corresponding table onto designer. By now, your changes in database will affect to LINQ-SQL.

    Also, you need to do some modification related with the changes in database to your formview settings, such as adding or removing fields and so on. Hope this helps you!

     

    Thanks.

    Sincerely,
    JanIvan Qian

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
  • Re: LinqDataSource with FormView update/insert LinqDataSourceValidationException

    05-07-2008, 10:41 AM
    • Loading...
    • dines
    • Joined on 05-04-2003, 6:04 AM
    • Germany
    • Posts 131

    Thanks for your reply. That is what I did  refreshed erverything. The SQL-Tables in VS, the Linqdatasource, the schema of the formview... but still had that issue Sad... I had to delete my whole linq-to-sql file and then it worked, very strange.

    Since I started from scratch with my new linq-to-sql file I did not have had any troubles. Hopefully I do not have to change something at database level again...

    I just wanted to know if other had the same Problem and thought that it's maybe worth to mention. But maybe that is just me...

    Regards

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter