This question is locked. New answers and comments are not allowed.
Hey!
I would like to update / edit an external list in Sharepoint using Silverlight. Im using client object model, so I got a class with properties representing all the columns in the list.
I'm using the RowEditEnded event, to catch the current row that was edited.. Now I need to get the current row somehow from Sharepoint External List and update it.
My primary key is not called ID so I cannot use getItemByID. Ive tried using a caml query to achieve the same thing. But then i'm having problem retrieving just that one row?.
Any idea what to do? I gotta say it's rather strange to think that everyone uses "ID" as primary.
I know there is a way to do this in the Sharepoint Shell script like this: "$SPItem = $SPList.Items | Where { $_["CUSTOMER_ID"] -eq "Value of field you want to search for" }"
Ive enclosed my RowEdited function, with comments. If it is to any help
Appreciate some help, I am really stuck.
I would like to update / edit an external list in Sharepoint using Silverlight. Im using client object model, so I got a class with properties representing all the columns in the list.
I'm using the RowEditEnded event, to catch the current row that was edited.. Now I need to get the current row somehow from Sharepoint External List and update it.
My primary key is not called ID so I cannot use getItemByID. Ive tried using a caml query to achieve the same thing. But then i'm having problem retrieving just that one row?.
Any idea what to do? I gotta say it's rather strange to think that everyone uses "ID" as primary.
I know there is a way to do this in the Sharepoint Shell script like this: "$SPItem = $SPList.Items | Where { $_["CUSTOMER_ID"] -eq "Value of field you want to search for" }"
Ive enclosed my RowEdited function, with comments. If it is to any help
Appreciate some help, I am really stuck.
private
void
EditingRowsGrid_RowEditEnded(
object
sender, GridViewRowEditEndedEventArgs e)
{
Sales editedRow = e.Row.DataContext
as
Sales;
//Uses the class made representing all the columns.
ClientContext editLoadData =
new
ClientContext(SPSite);
//Open site
List list = editLoadData.Web.Lists.GetByTitle(SPList);
//Get by title SPList variable
editLoadData.Load(list);
//Load it
CamlQuery query =
new
CamlQuery();
//initiate caml query
query.ViewXml =
"<View><Query><Where><Contains><FieldRef Name='CUSTOMER_ID'/><Value Type='Integer'>"
+ editedRow.CUSTOMER_ID.ToString() +
"</Value></Contains></Where></Query></View>"
;
ListItemCollection items = list.GetItems(query);
//Get the items using the caml query.
//Here i am stuck, I am not sure that the above works either, but here I made a try accessing the one row, I fetched from the list with items[0], didnt work. Any idea?
ListItem oListItem = items[0];
oListItem[
"test_column"
] = editedRow.test_column.Trim();
oListItem.Update();
editLoadData.ExecuteQueryAsync(succeededCallbackUpdate, failedCallback);
}