Creating a List from Custom List Template in SharePoint 2013
- using(ClientContext ctx = new ClientContext("http://mysite/"))
- {
- ListTemplateCollection ltc = ctx.Web.ListTemplates;
- ctx.Load(ltc);
- ctx.ExecuteQuery();
- ListTemplate listTemplate=null;
- foreach (ListTemplate lT in ltc)
- {
- if(lt.Name.Equals("My Custom List Template"))
- {
- listTemplate = lT;
- }
- }
- ListCreationInformation lc = new ListCreationInformation();
- lc.Title = "EmployeeList";
- lc.TemplateType = listTemplate.ListTemplateTypeKind;
- lc.Description = "This holds employee information";
- List newList = ctx.Web.Lists.Add(lc);
- ctx.ExecuteQuery();
- }
Programmatically Apply the filter to SharePoint List Default View
- string tempQuery= "<Where><Eq><FieldRef Name=\"Title\"/>"+
- "<Value Type=\"Text\">xyz</Value></Eq></Where>;
-
-
- SPList listView= oWeb.Lists[listName];
-
-
-
- for(int i = 0; i < listView.Views.Count; i++)
- {
-
-
- SPView view = listViewActual.Views[i];
-
- if(view.DefaultView)
- {
- oWeb.AllowUnsafeUpdates = true;
-
- view.Query = tempQuery;
- view.Update();
- oWeb.AllowUnsafeUpdates = false;
-
- }
- }
No comments:
Post a Comment