private List<MSAContact> GetFormattedContacts(string contacts, String[] pattern1, String[] pattern2)
        {
            try
            {
                List<MSAContact> lstMsaContacts = new List<MSAContact>();

                var lstContact = contacts.Split(pattern1, StringSplitOptions.None);

                foreach (var item in lstContact)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        var contactStr = item.Split(pattern2, StringSplitOptions.None);
                        if (contactStr.Length > 0)
                        {
                            MSAContact contact = new MSAContact();
                            contact.ContactId = Int32.Parse(contactStr[0]);
                            contact.ContactDetail = contactStr[1];

                            lstMsaContacts.Add(contact);
                        }
                    }
                }

                return lstMsaContacts;
            }
            catch (Exception ex)
            {
                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("SL.FG.FFL(MSAForm->GetFormattedContacts)", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);

                message_div.InnerHtml = "Something went wrong!!! Please Contact the administrator.";
                DisableControls();
            }

            return null;
        }
        private List<MSAContact> GetFormattedContactsByMSA(SPWeb oSPWeb, int msaId)
        {
            try
            {
                string listName = "MSAContactDetail";
                // Fetch the List
                SPList splistMSAContactDetail = oSPWeb.GetList(string.Format("{0}/Lists/{1}/AllItems.aspx", oSPWeb.Url, listName));

                List<MSAContact> lstMSAContact = new List<MSAContact>();

                if (splistMSAContactDetail != null)
                {
                    SPQuery query = new SPQuery();
                    SPListItemCollection spListItems;
                    // Include only the fields you will use.
                    query.ViewFields = "<FieldRef Name='ID'/><FieldRef Name='ContactDetail'/>";
                    query.ViewFieldsOnly = true;
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<Where>")
                         .Append("  <Eq>")
                         .Append("    <FieldRef Name='MSAID' />")
                         .Append("    <Value Type='Number'>" + msaId + "</Value>")
                         .Append("  </Eq>")
                         .Append("</Where>");

                    query.Query = sb.ToString();
                    spListItems = splistMSAContactDetail.GetItems(query);

                    for (int i = 0; i < spListItems.Count; i++)
                    {
                        SPListItem listItem = spListItems[i];
                        MSAContact contact = new MSAContact();
                        contact.ContactId = Convert.ToInt32(listItem["ID"]);
                        contact.ContactDetail = Convert.ToString(listItem["ContactDetail"]);

                        lstMSAContact.Add(contact);
                    }
                }

                return lstMSAContact;
            }
            catch (Exception ex)
            {
                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("SL.FG.FFL(MSAForm->GetFormattedContactsByMSA)", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);

                message_div.InnerHtml = "Something went wrong!!! Please Contact the administrator.";
                DisableControls();
            }

            return null;
        }