I have two sharepoint lists. (“ClassNameList”) and (“Notifications”) The (“Notifications”) has three columns: “classID” which is a lookup id from (“ClassNameList”), Title, and Boolean IsEvaluated.
In the (“Notifications”) I may have one or more items related to the same classID. For example: the first row : classID “20”, Title. ”Math”, IsEvaluated “Yes”. The second row: classID. “20”, Title. ”math ”, IsEvaluated “Yes”. I need to insert a third row with the same information but this time i need to update the column IsEvaluated of the first two rows to “No” and set the third row to “Yes”. So when I display the items in a gridview, i only need to display one item that is “Yes”. I don’t want to duplicate rows in my gird. I just need the last created. Here is what im trying to do.
try
{
using(SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using(SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList("Notifications ");
if(list!=null)
{
SPListItem NewItem = list.Items.Add();
{
web.AllowUnsafeUpdates = true;
NewItem["IsEvaluated"] = false; // How to iterate through the two rows?
NewItem["classID"] = id; ==> got it from query string
NewItem["Title"] = txtClassName;
NewItem["IsEvaluated"] = true;
}
}
}
}
}
catch(Exception ex)
{
Alert.Text = ex.Message.ToString();
}
It is tricky. Please help.