MOSS 2007 - Updating List Item status



Get list item status using CAML query and updating status progrmatically

 /// 
        /// Method to get listItem status 
        /// Author :Hima
        /// CopyRight :SyntaxHelp
        /// Created On :Feb 05 2010
        /// 
        /// 
        /// 
        public static void updateEmployeeStatus(string emailId, string status)
        {
            try
            {

                string eprList = ConfigurationSettings.AppSettings["EPRLIST"].ToString();
                string strSiteRoot = ConfigurationSettings.AppSettings["EPRSite"].ToString();
                SPSite eprSite = new SPSite(strSiteRoot);
                eprSite.AllowUnsafeUpdates = true;
                SPWeb eprSPweb = eprSite.OpenWeb();

                SPQuery queryEPR = new SPQuery();
                queryEPR.Query = "" + emailId + "";
                SPList eprSPList = eprSPweb.Lists[eprList];
                SPListItemCollection eprSPItemCollection = eprSPList.GetItems(queryEPR);
                SPListItem eprSPItem;

                if (eprSPItemCollection.Count > 0)
                {
                    eprSPItem = eprSPItemCollection[0];
                    eprSPItem["Status"] = status;
                    eprSPItem.Update();
                }
                eprSite.Dispose();
                eprSPweb.Dispose();
            }
            catch
            {

            }

        }

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.