如何通过其视图中的Lookup列获取与Sharepoint List关联的列

时间:2011-07-08 05:02:37

标签: sharepoint-2010

我在sharepoint 2010中有两个表。一个是包含部门名称及其位置的部门。另一个列表是Employee,它通过部门名称上的查找字段与部门相关联。

现在我想创建一个员工列表视图,其中包含员工列表和部门列表的列。但是,创建员工列表视图时,sharepoint 2010的默认视图创建功能不会显示部门列表的列

任何人都可以帮帮我

2 个答案:

答案 0 :(得分:1)

 SPFieldLookupValue value=new SpFiledlookupvalue(item["column name"]);
    string id=value.lookupid;//you can retrieve the text,id
    string text=value.lookuptext;

    SPList departmentList=new oweb.Lists["Department List"];
    SPQuery getDepartment=new SPQuery( )
    getDepartment.Query=  "<Where>  <Eq>  <FieldRef Name='ID' />
                                                  <Value Type='Counter'>id</Value>
                                                 </Eq>
                                        </Where>";
    SPListItemCollection departMentRow=departmentList.GetItems(getDepartment)

You can check this code for your reference....and query like what you want..

答案 1 :(得分:1)

在设置查找字段中,选择部门列表的必填字段,然后将这些字段添加到员工列表视图。

相关问题