Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 开发SharePoint自定义web部件。如何呈现查找字段?_C#_.net_Sharepoint_Web Parts - Fatal编程技术网

C# 开发SharePoint自定义web部件。如何呈现查找字段?

C# 开发SharePoint自定义web部件。如何呈现查找字段?,c#,.net,sharepoint,web-parts,C#,.net,Sharepoint,Web Parts,我需要将列表中的查找字段呈现为带有弹出对话框的链接(与在默认SharePoint 2010列表视图中呈现查找字段的方式相同)。如果我有包含查找字段的SPListItem对象,我该怎么做?也许有一些控件可以渲染查找字段 protected void Page_Init(object sender, EventArgs e) { SPQuery query = new SPQuery(); query.Query = "some query here"; SPListItem

我需要将列表中的查找字段呈现为带有弹出对话框的链接(与在默认SharePoint 2010列表视图中呈现查找字段的方式相同)。如果我有包含查找字段的SPListItem对象,我该怎么做?也许有一些控件可以渲染查找字段

protected void Page_Init(object sender, EventArgs e)
{
    SPQuery query = new SPQuery();
    query.Query = "some query here";
    SPListItemCollection items = __list.GetItems(query);
    foreach (SPListItem item in items)
    {
        // render item["lookup_field_name"] somehow
    }
}

如果SPQuery对象检索到一个列表项,则该列表项中将包含一个值,您只需检查该值是否为null

foreach (SPListItem item in items)
{
    if(item != null)
    {
        // render item["lookup_field_name"] somehow
    }
}
这意味着,当您请求查找列时,它们不会被填充,而是被创建时所携带的内容填充

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