为什么MultipleLookupField setter不起作用,我该怎么做才能使它起作用? [英] Why MultipleLookupField setter is not working and what can i do to make it work?
问题描述
有人可以确认他们有同样的问题吗?我在SP2013,VS2013上使用即时通讯,在Microsoft.SharePoint v15.0.0.0上也有参考
can someone confrim they have the same problem? Im with SP2013, VS2013 and i have a reference on Microsoft.SharePoint v15.0.0.0
我运行以下简化代码:
LookupField lf = new LookupField();
MultipleLookupField mlf = new MultipleLookupField();
lf.Value = new SPFieldLookupValueCollection("1;#1;#2;#2;#3;#3");
mlf.Value = new SPFieldLookupValueCollection("1;#1;#2;#2;#3;#3");
我得到这个结果:
为什么mlf没有设置值,有人知道如何设置值吗?
Why mlf is not setting the value, do someone have an idea how to set the value?
获取或设置查找字段的值.
Gets or sets the values of the lookup fields.
推荐答案
我认为 将值设置为 直接 MultipleLookupField .
I think it is not the correct way to set value to MultipleLookupField directly.
要正确使用 MultipleLookupField ,我们可以执行以下操作.
To use MultipleLookupField correctly, we can do as below.
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
SPList list = SPContext.Current.Web.Lists["CustomList"];
MultipleLookupField mlf = new MultipleLookupField();
mlf.ControlMode = SPControlMode.Edit;
mlf.FieldName = "Attendees";
mlf.ItemId = list.Items[1].ID;
mlf.ListId = list.ID;
mlf.ID = "MultipleLookupField4";
this.Controls.Add(mlf);
}
}
如果必须为 MultipleLookupField 赋值,则可以选择另一种前端代码,例如html和JS.
If you have to assign value to MultipleLookupField, you can choose another way of front-end code like html and JS.
最诚挚的问候,
李刘
这篇关于为什么MultipleLookupField setter不起作用,我该怎么做才能使它起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!