如何从sharepoint 2010中的列表视图中获取数据 [英] how do I fetch data from a listview in sharepoint 2010
本文介绍了如何从sharepoint 2010中的列表视图中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义表单,数据存储在特定列表的列表视图中。
现在我想根据列表视图中的2列从该列表视图中获取数据。我该怎么办?
I have a custom form, the data is getting stored in listview of a particular list.
now i want to fetch data from that listview based on 2 columns present in that listview. how do I go about it?
推荐答案
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='Modified' Ascending='TRUE'/></OrderBy>" +
"<Where><And>" +
"<Eq><FieldRef Name='status'/><Value Type='Text'>" + DocType + "</Value></Eq>" +
"<Eq><FieldRef Name='Department1'/><Value Type='Lookup'>" + Department + "</Value></Eq>" +
"</And></Where>";
using(SPweb newweb = newsite.open()){
SPlist spl = newweb.list.trygetlist("");
datatable dt = spl.getitem(query).getdatatable();
这只是示例
this is just example
System.data;
Microsoft.sharepoint;
using(SPsite newsite = new SPsite("name of your website")){
using(SPweb newweb = newsite.open()){
SPlist spl = newweb.list.trygetlist(" name of your list ");
datatable dt = spl.getitem("add CAML query here").getdatatable();
foreach(datarow dr in dt.rows)
dr["column name "].toString();
}
这篇关于如何从sharepoint 2010中的列表视图中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文