从人员选取器收集数据

时间:2012-12-07 05:53:19

标签: sharepoint

我想收集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;
            }
  }

帮助高度赞赏。

1 个答案:

答案 0 :(得分: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;
        }
    }

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