Answered ASP Dropdown error

  • Wednesday, April 11, 2012 4:56 PM
     
     

    Hi,

    I'm trying to insert a ASP dropdown into my page,  bound to a SPDatasource.

    The data source is a SP list,  and one of my fields are populated by a people picker.

    I want to populate my Dropdown by that column.   The column name is Content_Manager.

    When I create my dropdown,  I have the options of selecting what fields I want to display in the dropdown.  
    My choices are:
    Content Manger
    Content Manger.id
    Content Manger.title
    Content Manger.span

    If I select the 'Content_Manager' field,  then the page will display fine and the dropdown populates.   But it populates with everything about the person, the ID,  their name,  domain name  etc.   So it's pretty much unreadable to a normal person.

    I just want the name to appear,  and that should be the Content_Manger.title  field.   I'm looking at the SPDatasource,  and I don't actually see that field listed,  and no way to add it in the configure datasource window .  I tried to manually add it via the code,  but that doesn't work either.

    Is there a way to do what I need?

    Thanks,

All Replies

  • Wednesday, April 11, 2012 6:25 PM
     
     

    Another question I have in regards to databound ASP dropdowns.  HOw do you remove duplicate values from the list?

    Since this is pulling from a list,  I'm seeing every instance of the values.   I would like to remove the duplicates,  but I havne't been able to find a way to do this yet.

  • Thursday, April 12, 2012 3:10 PM
     
     
    Anyone have any ideas?
  • Friday, April 13, 2012 9:26 AM
    Moderator
     
     Answered

    Hi ,

    There is not any way to bind the dropdown to the Content Manger.title .This column doesn’t actually exist although it is listed in the data source .You can add another single line of text  column in the list to get the value of the people picker column .Update the text box column using a workflow which will start when an item is created or edited .Return the people picker column as Display Name ;Semicolon delimited .Then bind this dropdown to the text column .So that the drop down list control will only show the display names of users .

    Thanks

    Entan Ming

    TechNet Community Support

  • Friday, April 13, 2012 5:09 PM
     
     

    Hi

    Thanks for your help,

    The workflow idea I actually thought of yesterday,  but it's not quite working the way I need.  Maybe I've done it differently they how you described it.

    I have a workflow that runs when an item is created/edited and updates a text field with the value of the people picker column.    It works,  but it saves it as domain/alias  instead of their full name (john doe)

    I'm not quite sure though,  when you say
    "Return the people picker column as Display Name ;Semicolon delimited "

    What do you mean by this,  and where do I need to set this?

    Also do you have a suggestion on removing duplicates from the dropdown?

  • Friday, April 13, 2012 8:37 PM
     
     

    Why are you using an <asp:DropDownList> instead of a <SharePoint:DVDropDownList>?


    Brian T. Shell

  • Friday, April 13, 2012 9:13 PM
     
     

    I'm using this method to have dropdowns to be used as multiple filters.

    It all works great,  I just need to figure out this column that is a people picker, displaying the name and removing the duplicates.

  • Monday, April 16, 2012 12:34 AM
     
     

    anyone have any other suggestions?

    If I could at least find a way to remove the duplicates from the dropdown,  that would be a big step.

  • Tuesday, April 17, 2012 9:15 AM
    Moderator
     
     Answered

    Hi ,

    Return the column as Display Name; Semicolon delimited is set in the workflow action :

    In order to get rid of the duplicated values in the drop down list control ,you can either use javascript to hide the choices or you can Configure new SqlDataSource and pull distinct SharePoint list data from SQL Server .

    You need rewrite the SelectCommand property as below:

    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ProviderName="System.Data.SqlClient"

    ConnectionString="Data Source=EWIN2KSQLVS;Initial Catalog=WSS_Content_8888;User ID=new;Password=new"

    SelectCommand="SELECT distinct dbo.UserData.nvarchar1

    FROM dbo.Lists ">

    </asp:SqlDataSource>

    For more information ,please refer to this site:

    Duplicate entries in drop down list source related to SP list: http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/6b8f19dc-82de-471a-96b0-19a723995776/

    Thanks

    Entan Ming

    TechNet Community Support