Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Beckert 193 posts 469 karma points
    Nov 02, 2015 @ 10:21
    Thomas Beckert
    0

    Set Property Value of a CheckboxList

    Hi,

    I create a node by code and want to set the value of a checkboxlist, but got an exception.

    What do I do so far:

     var cs = ApplicationContext.Current.Services.ContentService;
                        var betrieb = cs.CreateContent("Node-Name", 1051, "Kunde", 0);
    
    betrieb.SetValue("betriebsname", "value of betriebsname);
    //Kueche
    List<string> kueche = new List<string>();
    
                        dsHbiGOldTableAdapters.KuecheTableAdapter dsK = new dsHbiGOldTableAdapters.KuecheTableAdapter();
                        dsHbiGOld.KuecheDataTable dtK = dsK.GetKueche(objRow.idGastronom.Trim());
    
                        foreach(dsHbiGOld.KuecheRow objK in dtK.Rows)
                        {
                            kueche.Add(objK.Bezeichnung);
                        }
    
                        betrieb.SetValue("kueche", JsonConvert.SerializeObject(kueche));
    

    The Exception I got:

    System.Data.SqlClient.SqlException (0x80131904): Zeichenfolgen- oder Binärdaten würden abgeschnitten. Die Anweisung wurde beendet. bei System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) bei System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) bei System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) bei System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) bei System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() bei System.Data.SqlClient.SqlDataReader.get_MetaData() bei System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) bei System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) bei System.Data.SqlClient.SqlCommand.ExecuteScalar() bei StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() bei Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClassa.b__9() bei Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func1 func) bei Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) bei Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command, RetryPolicy retryPolicy) bei Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command) bei Umbraco.Core.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco) bei Umbraco.Core.Persistence.Database.Insert(Object poco) bei Umbraco.Core.Persistence.Repositories.ContentRepository.PersistNewItem(IContent entity) bei Umbraco.Core.Persistence.Repositories.RepositoryBase2.PersistNewItem(IEntity entity) bei Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action1 transactionCompleting) bei Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() bei Umbraco.Core.Services.ContentService.SaveAndPublishDo(IContent content, Int32 userId, Boolean raiseEvents) bei Umbraco.Core.Services.ContentService.SaveAndPublishWithStatus(IContent content, Int32 userId, Boolean raiseEvents) bei umbWebPortal.umbStartup..ctor() ClientConnectionId:0493881d-7de6-4b74-933d-05fc3004f64b Fehlernummer (Error Number):8152,Status (State):13,Klasse (Class):16

    What do I do wrong?

  • Sören Deger 733 posts 2844 karma points c-trib
    Nov 02, 2015 @ 13:00
    Sören Deger
    100

    Hi Tom,

    maybe this can help you: https://our.umbraco.org/forum/umbraco-pro/contour/44128-Saving-checkboxlist-values-to-custom-datatype-in-umbraco

    You must set the prevalues (IDs) and not the values for your checkboxlist.

    Hope this helps?

    Cheers, Sören

Please Sign in or register to post replies

Write your reply to:

Draft