Affichage des articles dont le libellé est CAML QUERY. Afficher tous les articles
Affichage des articles dont le libellé est CAML QUERY. Afficher tous les articles

jeudi 27 mars 2014

Get élement from Liste sharepoint avec une CAML Query

  public static String LoadDocById(int idDoc)
  {
            String etape = "Debut Methode";
            SPList list = SPContext.Current.Web.Site.RootWeb.Lists["Docs"];
            if (list != null)
            {
                etape = "Litse non null";
string caml = @"<Where><Eq><FieldRef Name='ID' /><Value                     Type='Text'>2428</Value></Eq></Where>";

                SPQuery qry = new SPQuery();
                qry.Query = caml;
                SPListItemCollection items = list.GetItems(qry);
                            

foreach (SPListItem item in items)
                    {
                        String nomFichier = "";
                        if (item2["Nom"] != null)
                        {
                            nomFichier = item["Nom"].ToString();
                        }

                        if (item2["ID"] != null)
                        {
                            nomFichier = item["ID"].ToString();
                        }
                    }
                }

 return etape;

            }