Search code examples
c#sharepointcheckboxsharepoint-2013multichoiceitems

Checked multiple checkbox using c# in Sharepoint 2013


I have a problem! :( I programming in C# for Visual Studio 2012 and I am building an intranet that uses data from Sharepoint 2013. I have a problem in the register.

In SharePoint 2013, I have a list. In that list, one of the columns is of type "choice". When from C# I do calls to save the information, apparently is saved. But then, after seeing the results in Sharepoint 2013 I see is not so the information is not saved.

In SharePoint 2013 only save a default checkbox element (first element) but no save the correct selection.

My code:


SharePointConnector.SharePointEntities.TestDeInteresItem test = new SharePointConnector.SharePointEntities.TestDeInteresItem();

List<SharePointConnector.SharePointEntities.TestDeInteresInteresesPersonalesValue> personalList = new List<SharePointConnector.SharePointEntities.TestDeInteresInteresesPersonalesValue>();//0

test.AlumnoId = student.Identificador;
string[] auxPersonal = possibleInterest.Personal.Split(',');
for (int i = 0; i < auxPersonal.Length; i++)
{
        string s = auxPersonal[i];
        if (s.Length > 0)
        {
               var allInterest = englishDataContext.TestDeInteresInteresesPersonales.ToList();
               var element = allInterest.Where(x => x.Value.Equals(s)).FirstOrDefault();
               if (element != null)
               {
                            SharePointConnector.SharePointEntities.TestDeInteresInteresesPersonalesValue personal = new SharePointConnector.SharePointEntities.TestDeInteresInteresesPersonalesValue();
                            personal.Value = element.Value;
                            test.InteresesPersonales.Add(personal); //1
               }
        }
}

englishDataContext.AddToTestDeInteres(test); //2
englishDataContext.SaveChanges(); //3

--- //0 -> Initially, the list of elements (column when to type is election) is empty.

//1 -> The element is added successfully

//2 -> In this step, the information to added is correctly...

//3 -> ...but save allinformation correctly less the item cited (column when to type is election). This element is save default election (First element to checkbox)

Any ideas?


Solution

  • I've already solved the problem. The context was wrong.

    http://msdn.microsoft.com/en-us/library/office/fp179912%28v=office.15%29.aspx