如何判断PeopleEditor的值为空

在sharepoint开发中,我们经常会用到PeopleEditor这一控件,最近我在写程序的时候用到了,开始的时候不知道怎么用,后来问题解决啦,现在写出来,和大家共享一下,希望对sharepoint初学者有帮助

<SharePoint:PeopleEditor ID="peOwner" runat="server" Rows="1" ValidatorEnabled="True"  MultiSelect="False" 
                 Width="160px" AllowEmpty="true"/>

其中,AllowEmpty:指PeopleEditor能否为空,true:表示允许为空,false:表示不允许为空   默认为true

如果允许为空,当点击提交按钮,向列表中添加数据的时候,要先判断该PeopleEditor是否为空,如果为空的话,就不向列表中添加该数据,如果不为空的话则向列表中添加数据,那么如何判断PeopleEditor为空呢

string strID = "";
foreach (PickerEntity p in this.peOwner.ResolvedEntities)
{
      strID += p.EntityData["SPUserID"].ToString() + ";#;#";s
}

判断strID是否为空,如果strID为空则说明PeopleEditor没有填写任何值,如果不为空,则说明PeopleEditor有值

posted @ 2011-11-24 10:22  如果爱忘了  阅读(466)  评论(0编辑  收藏  举报