1

我想收集在 PeoplePicker 中添加的用户名,并在单击自定义 aspx 页面的“添加”按钮时将它们显示在文本框中。

我尝试了很多代码,但它不起作用。

这是我的代码:

protected void btnpicker_Click(object sender, EventArgs e)
        {
 for (int i = 0; i < userPicker.ResolvedEntities.Count; i++)
            {
                PickerEntity picker = (PickerEntity)userPicker.ResolvedEntities[i];
                Hashtable hstEntityData = picker.EntityData;
                string accountName = Convert.ToString(hstEntityData["AccountName"]);
                txtPicker.Text = "Count" + hstEntityData.Count.ToString();
                txtPicker.TextMode = TextBoxMode.MultiLine;
            }
  }

帮助高度赞赏。

4

1 回答 1

2

试试下面的代码。

protected void btnpicker_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < userPicker.ResolvedEntities.Count; i++)
        {
            PickerEntity picker = (PickerEntity)userPicker.ResolvedEntities[i];
            yourTextBox.Text = "Count: " + new SPFieldUserValue(yourSPWebObject, Convert.ToInt32(picker.EntityData["SPUserID"]), picker.Key).User.Name;
        }
    }

此代码将在您的文本框中提供所有用户的名称。

于 2012-12-07T06:50:10.023 回答