数据从下拉列表传递到表单 [英] Data passing to form from dropdown
问题描述
我有一个查找清单,在查找清单上,它与用户相关.在该字段中,它具有添加到下拉菜单中的其他字段以将数据解析到列表中.因此,这些是次要项目.因此它们出现在列表中,但是没有通过
数据到表格.有人可以协助提供例子吗?我添加了一张图片以显示通过了什么.
I have a list that is a look up, on the lookup, it is tied to a user. In that field it has additional fields that are added to the dropdown to parse data to the list. So these are secondary items. So they appear in the list, however they do not pass the
data to the form. Can someone assist in providing an example? I added an image to show what is passed.
李·莫索尔(Lee Mossolle)
Lee Mossolle
推荐答案
我们可以使用C#代码将查找附加字段添加到列表中,然后它将以列表形式出现:
We can add the lookup additional fields to the list using C# code, then it will appear in the list form:
string mainListName = "Countries"; //Name of Lookup List
string lookupListName = "Application"; //Name of Main List Needs to add additional field to lookup
string lookupColAdditionalFieldDisplayName = "CountryCode"; //Display name of additional field in main list
string pLookupKeyName = "CountryTitle"; //Name of parent lookup field in main List
string additionalLookupFieldName = "Code"; //Name of additional Field in lookup list
//Main List
SPList mainlst = w.Lists[lookupListName];
//Lookup List
SPList lookuplst = w.Lists[mainListName];
//Main List Fields
SPFieldCollection col = mainlst.Fields;
//Lookup Primary Key
SPFieldLookup spPrimaryField = ((SPFieldLookup)col[pLookupKeyName]);
//Create Additional Field its name in lookup Field1 with display name in list TestDisplayName
SPFieldLookup field = (SPFieldLookup)mainlst.Fields.CreateNewField(SPFieldType.Lookup.ToString(), lookupColAdditionalFieldDisplayName);
field.LookupList = spPrimaryField.LookupList;
field.LookupWebId = spPrimaryField.LookupWebId;
field.LookupField = additionalLookupFieldName;
field.PrimaryFieldId = spPrimaryField.Id.ToString();
field.ReadOnlyField = true;
field.AllowMultipleValues = spPrimaryField.AllowMultipleValues;
field.UnlimitedLengthInDocumentLibrary = spPrimaryField.UnlimitedLengthInDocumentLibrary;
field.Direction = spPrimaryField.Direction;
SPAddFieldOptions op = SPAddFieldOptions.Default;
//Add Additional Field to main list
mainlst.Fields.AddFieldAsXml(field.SchemaXml, true, op);
更多信息:
http://sharepointserver-2007. blogspot.sg/2010/12/add-additional-column-to-sharepoint.html
谢谢
这篇关于数据从下拉列表传递到表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!