本文介绍了如何使用Spquery和Caml在Sharepoint列表中插入新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码从列表中检索特定项目,

i have the following code to retrieve particular item from the list ,

SPWeb mySite = SPContext.Current.Web;

            SPList li = mySite.Lists["List"];

                SPQuery oQuery = new SPQuery();

                oQuery.Query = string.Concat("<Where><Eq>",
                                                    "<FieldRef Name='ID'/>",
                                                    "<Value Type='Number'>6</Value>",
                                              "</Eq></Where>");


                oQuery.ViewFields = string.Concat(
                                       "<FieldRef Name='ID'/>",
                                       "<FieldRef Name='Title'/>",
                                       "<FieldRef Name='Email'/>",
                                       "<FieldRef Name='Department'/>");

                oQuery.ViewFieldsOnly = true;
                SPListItemCollection collListItems = li.GetItems(oQuery);

          

                foreach (SPListItem oListItem in collListItems)
                {
                    Label9.Text = oListItem["Title"].ToString();
                }

i want to ask how can i insert item in the list .. can u give me idea of doing this in server object model .. and what will be the query in this case ??

推荐答案


这篇关于如何使用Spquery和Caml在Sharepoint列表中插入新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 06:00