码迷,mamicode.com
首页 > 其他好文 > 详细

SharePoint列表数据展现方法

时间:2014-05-01 18:38:35      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   ext   javascript   color   get   int   html   

方法1:

mamicode.com,码迷
Guid guid = new Guid ("{8238B046-EC5F-46B6-8E18-028F77EC2620}");
SPSite Asite = new SPSite ("http://mosslt/");
SPList list = Asite.RootWeb.Lists[guid];
SPQuery query = new SPQuery();
query.Query = @"<OrderBy>
              <FieldRef Name=ID‘ />
              </OrderBy>
              <Where>
              <Gt>
              <FieldRef Name=‘ID‘ />
              <Value Type=‘Counter‘>0</Value>
              </Gt>
              </Where>"; //顺序按ID排,条件为ID大于0
query.ViewFields = @"
                   <FieldRef Name=‘LinkTitle‘ />
                   <FieldRef Name=‘htchange‘ />
                   <FieldRef Name=‘htinfo‘ />";//要显示在前的三字段,后而会自动回上ID,Created


this.GridView1.DataSource = list.GetItems (query).GetDataTable();
this.GridView1.DataBind();
mamicode.com,码迷

方法2:

mamicode.com,码迷
using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
{
    SPList oList = oWebsiteRoot.Lists["List_Name"];
    SPQuery oQuery = new SPQuery();
    oQuery.ViewFields = "<FieldRef Name=‘Field1‘/>" +"<FieldRef Name=‘Field2‘/>";
    oQuery.Query = "<Where><Geq><FieldRef Name=‘Field2‘/>" +"<Value Type=‘Number‘>1000</Value></Geq></Where>";
    SPListItemCollection collListItems = oList.GetItems (oQuery);
    foreach (SPListItem oListItem in collListItems)
    {
        Response.Write (SPEncode.HtmlEncode (oListItem.Xml) + "<BR>");
    }
}
mamicode.com,码迷

 方法3:

mamicode.com,码迷
<View>
  <Query>
    <OrderBy>
    <FieldRef Name=‘ID‘ />" + "</OrderBy>
    <Where>
      <Or>
        <Geq>
        <FieldRef Name=‘Field1‘ />" + "
        <Value Type=‘Number‘>1500</Value></Geq>
        <Leq>" + "
        <FieldRef Name=‘Field2‘ />
        <Value Type=‘Number‘>500</Value>" + "</Leq>
      </Or>
    </Where>
  </Query>
  <ViewFields>" + "
  <FieldRef Name=‘Title‘ />" + "
  <FieldRef Name=‘Field1‘ />
  <FieldRef Name=‘Field2‘ />" + "
  <FieldRef Name=‘Field3‘ />
  <FieldRef Name=‘Field4‘ />" + "</ViewFields>
  <RowLimit>100</RowLimit>
</View>
mamicode.com,码迷
mamicode.com,码迷
using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Site_Name"])
{
    SPList oList = oWebsite.Lists["List_Name"];
    SPQuery oQuery = new SPQuery();
    oQuery.ViewXml = "上表";
    SPListItemCollection collListItemsAvailable = oList.GetItems (oQuery);
    foreach (SPListItem oListItemAvailable in collListItemsAvailable)
    {
        Response.Write (SPEncode.HtmlEncode (oListItemAvailable.Xml) +"<BR>");
    }
}
mamicode.com,码迷

 

SharePoint列表数据展现方法,码迷,mamicode.com

SharePoint列表数据展现方法

标签:style   blog   class   code   java   ext   javascript   color   get   int   html   

原文地址:http://www.cnblogs.com/yixiaozi/p/3702646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!