We have to refer the Client side DLL firstly
using sp = Microsoft.SharePoint.Client;
Creating sample JSON
PriceValuesJSON = @"[
{
""Title"": ""SN"",
""value"": 41.4
},
{
""Title"": ""GN"",
""value"": 109
}
]";
Loop the values:
List<PriceValue_Item> PriceValuesList = JsonConvert.DeserializeObject<List<PriceValue_Item>>(PriceValuesJSON);
foreach (PriceValue_Item obj in PriceValuesList)
{
createItemSharePointList_PriceValue(obj.Title, obj.value, filterSheetID);
}
public void createItemSharePointList_PriceValue(string Title, double value, int filterSheetID)
{
sp.ClientContext clientContext = new sp.ClientContext("siteURL");
sp.List oList = clientContext.Web.Lists.GetByTitle("MyPrice");
sp.ListItemCreationInformation itemCreateInfo = new sp.ListItemCreationInformation();
sp.ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = Title.ToString();
oListItem["value"] = value;
oListItem["ExcelInfo"] = filterSheetID;
oListItem.Update();
clientContext.ExecuteQuery();
}
using sp = Microsoft.SharePoint.Client;
Creating sample JSON
PriceValuesJSON = @"[
{
""Title"": ""SN"",
""value"": 41.4
},
{
""Title"": ""GN"",
""value"": 109
}
]";
Loop the values:
List<PriceValue_Item> PriceValuesList = JsonConvert.DeserializeObject<List<PriceValue_Item>>(PriceValuesJSON);
foreach (PriceValue_Item obj in PriceValuesList)
{
createItemSharePointList_PriceValue(obj.Title, obj.value, filterSheetID);
}
public void createItemSharePointList_PriceValue(string Title, double value, int filterSheetID)
{
sp.ClientContext clientContext = new sp.ClientContext("siteURL");
sp.List oList = clientContext.Web.Lists.GetByTitle("MyPrice");
sp.ListItemCreationInformation itemCreateInfo = new sp.ListItemCreationInformation();
sp.ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = Title.ToString();
oListItem["value"] = value;
oListItem["ExcelInfo"] = filterSheetID;
oListItem.Update();
clientContext.ExecuteQuery();
}
Comments
Post a Comment