标签:style blog class code java ext javascript color get int html
方法1:
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();
方法2:
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>"); } }
方法3:
<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>
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>"); } }
SharePoint列表数据展现方法,码迷,mamicode.com
标签:style blog class code java ext javascript color get int html
原文地址:http://www.cnblogs.com/yixiaozi/p/3702646.html