I have one SharePoint List. From Excel I will store the values in Data-table and fetch the values to List.If new values are adding to list is no problem.
If item is already there i want to update the item to list.
In my Datatable here I was changed the CanNum -1
to CanNum -update. So I want to compare sharepoint list items and datatable. In datatble I want to store only modified values after I want to update in list.
Here is my code :
if (oItems != null)
{
///Item updating
Hashtable htValues = new Hashtable();
string ID = oItems.ID.ToString();
foreach (SPListItem items in sqlfields)
{
string columns = items["Title"].ToString();
string columns1 = items["Fields"].ToString();
DataTable changedRecordsTable = dt.GetChanges(DataRowState.Modified);
if (changedRecordsTable!=null)
{
if (changedRecordsTable.Columns.Contains(Sqlcolumns))
{
if (!htValues.Contains(columns1 ))
htValues.Add(columns1 , dr[columns]);
}
}
}
///Using AddUpdateSqlItem method Update Product list witH SQL data's.
oItems = UpdateItem(currWeb, olistname, ID, htValues);
I was tried this DataTable changedRecordsTable = dt.GetChanges(DataRowState.Modified); changedRecordsTable comes null.
In hashtable i want to add only modified values.
Based on that image i want to store only txtCan_ReqNum value to hastable.
How can i do this.Someone help for this. Thanks in Advance.