Posts

creat a table using stirngbilder

sb.Append("<div> ");                                     sb.Append("<table style=\"float:left\">");                                     sb.Append("<tr>");                                     sb.AppendFormat("<td style=\"padding-left: 10px;\">{0}</td>", "<img src='" + imagepath + "'/>");                                     sb.Append("</tr>");                                     sb.Append("<tr>");                            ...

SpAttachent binding to a grid

if (items.Attachments.Count > 0)                                     {                                         foreach (String attachmentname in items.Attachments)                                         {                                            string attachmentAbsoluteURL = items.Attachments.UrlPrefix + attachmentname;                                             imagepath = attachmentAbsoluteURL.ToString();                   ...

person or group value into a collection

 SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Team");                             userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Team"].ToString());                             foreach (SPFieldUserValue user in userFieldValueCollection)                             { do your stuff here }

Get SPLinked list Data and Bind it a Visual Webpart

private void GetMoreEvents()         {             using (SPSite osite = new SPSite(SPContext.Current.Web.Url))             {                 using (SPWeb oweb = osite.OpenWeb())                 {                     SPList olist = oweb.Lists.TryGetList("More Events");                     SPListItemCollection collListItems = olist.Items;                     DataTable dt = new DataTable();                     dt.Columns.Add("Attachments", typeof(string));                     dt.Columns.Add("Title", typeof(string));                 ...

Binding list to multiple Grids using Camel Querry

private void GetSmartTools()         {             using (SPSite site = new SPSite(SPContext.Current.Web.Url))             {                 using (SPWeb web = site.OpenWeb())                 {                     SPList list = web.Lists.TryGetList("Smart Tools");                     if (list != null)                     {                         SPQuery query = new SPQuery();                         string stringQuery = string.Format(@"<Where><Eq><FieldRef Name='Country' /><Value Type='LookUp'>{0}</Value></Eq></W...

Binding a Attachment to a Visual Webpart in sharepoint 2013

 private void GetMoreCEO()         {             using (SPSite osite = new SPSite(SPContext.Current.Web.Url))             {                 using (SPWeb oweb = osite.OpenWeb())                 {                     SPList olist = oweb.Lists.TryGetList("CEOMessage");                     SPListItemCollection collListItems = olist.Items;                     DataTable dt = new DataTable();                     dt.Columns.Add("Attachments", typeof(string));                     dt.Columns.Add("Title", typeof(string));                 ...

Get data from two list in sharepoint 2013

private void GeEmployeDetails()         {             using (SPSite osite = new SPSite(SPContext.Current.Web.Url))             {                 using (SPWeb oweb = osite.OpenWeb())                 {                     SPList EmployeeAchievmentslist = oweb.Lists.TryGetList("EmployeeAchievments");                     SPList EmpBasicInfolist = oweb.Lists.TryGetList("EmpBasicInfo");                     SPQuery query = new SPQuery();                     string Querry = "<GroupBy> <FieldRef Name='Title' Ascending='True' /></GroupBy>";                     quer...