I am building a Silverlight application that will run on a SharePoint Silverlight Web Part. The data for the application is coming from a SQL Server database. Using SharePoint's External Content Type, I have created a set of lists from the database tables. Using SharePoint.Client.ClientContext I have been able to read the lists into my application and display the data.
Now I need to make changes to the data through the application back to the SharePoint Lists which will then update the database. From what I can tell, the application shows that the data updates from the application are being written to the lists. But when I examine the list on SharePoint it shows the original data. Also the database table is not updated.
Is there something that I am not setting up correctly with the SharePoint lists that the application is not being allowed to pass through the updates?
The following is the code I have for updating the list:
public void UpdateSPList()
{
_syncContext = SynchronizationContext.Current;
clientContext = ClientContext.Current;
foreach (clsStatus objStat in colStatus)
{
if (objStat.ToBeUpdated)
{
try
{
objLoadStatus.MessError += "Status: " + objStat.StatusID;
objLoadStatus.MessError += "\r\n lstStIt: " + lstStIt.Count.ToString();
lstIm = clientContext.Web.Lists.GetByTitle("Status").GetItemById(objStat.StatusID);
lstIm["StatusID"] = objStat.StatusID.ToString();
lstIm["Status"] = objStat.Status;
lstIm["StatusOrder"] = objStat.StatusOrder.ToString();
if (objStat.IsActive)
lstIm["IsActive"] = "1";
else
lstIm["IsActive"] = "0";
lstIm.Update();
clientContext.ExecuteQueryAsync(onReqSucc3, objReqFail2);
objStat.ToBeUpdated = false;
}
catch (Exception ex)
{
objLoadStatus.MessError += "\r\n" + ex.Message;
}
}
}
}
private void onReqSucc3(object sender, ClientRequestEventArgs cre)
{
_syncContext.Post(OnSucceedUpdateStatus, null);
}
private void OnSucceedUpdateStatus(object sender)
{
}
private void objReqFail2(object sender, EventArgs e)
{
}