Thursday, February 11, 2010

how to iterate through a hashtable:

how to iterate through a hashtable
if you have a hashtable and if you want to extract key/value pair;iterating through a hashtable://declare and define Hashtable htItem = new HashTable();
//now loop thru the key /value pair
foreach (DictionaryEntry de in htItem){splstitem[de.Key.ToString()] = de.Value.ToString();}*********************************suppose if you have acworkflow attached in your custom splist and if you wanna update the workflow task belwo is the LOC:we need to use the SPWorkflowTask.AlterTask. the most imp.part here is ht: a hashtable.
public string UpdateWorkflowTasks(Hashtable ht, int TaskID){string strRequestorsID = string.Empty;using (SPSite site = new SPSite(strUrl)){using (SPWeb web = site.OpenWeb()){web.AllowUnsafeUpdates = true;try{SPListItem taskItem = null;SPList listTasks = web.Lists["Tasks"];taskItem = listTasks.Items.GetItemById(TaskID);SPWorkflowTask.AlterTask(taskItem, ht, false);strRequestorsID = Convert.ToString(taskItem["strRequestorsID "]);}catch (Exception ex){
}web.AllowUnsafeUpdates = false;}}return strRequestorsID;

No comments: