locked
Populating Dropdown RRS feed

  • Question

  • Hi All..

    I want populate values from a sharepoint list to a dropdown. But i have to achieve this task by using designer.How can i do this??

    Saturday, February 23, 2013 5:02 AM

Answers

  • Thanks Mohammad Nizamuddin for your time..I am creating a custom .aspx page. I want to add a drop down box which should have the the values of one particular column in a list. How do i write the ECMA script. I read one article but it was not clear.

    here is the code

    <script language="ecmascript" type="text/ecmascript"> 
            var listItem;
            var list;
            var clientContext;
            function getSetListItem() {
                this.clientContext = SP.ClientContext.get_current();
                if (this.clientContext != undefined && clientContext != null) {
                    var webSite = clientContext.get_web();
                    this.list = webSite.get_lists().getByTitle("Custom");
                    this.listItem = list.getItemById(3);
                    clientContext.load(this.listItem);
                    this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
    Function.createDelegate(this, this.OnLoadFailed));
                }
            } 
            function OnLoadSuccess(sender, args) {
                var value = this.listItem.get_item("SampleOne");
                this.listItem.set_item("SampleTwo", value);
                this.listItem.update();
                this.clientContext.load(this.listItem);
                this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess1),
    Function.createDelegate(this, this.OnLoadFailed));
            } 
            function OnLoadSuccess1(sender, args) {
                alert(this.listItem.get_item("SampleTwo"));
            } 
            function OnLoadFailed(sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            }</script>
        <input id="btnGetSetListItem" onclick="getSetListItem()" type="button" value="Get & Set List Item" />
    

    check the detail here

    http://www.c-sharpcorner.com/UploadFile/anavijai/get-and-set-the-list-item-value-in-sharepoint-2010-using-ecm/


    Mark this post as answer if this resolves your issue.


    Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin

    Saturday, February 23, 2013 4:21 PM

All replies

  • are you creating a custom SharePoint page? you might want to write ECMA script to fetch the data and bind it to drop down

    If you have a list form then you can just have a look up column added in to the new list and choose the column of the parent list which you want to display as a drop down


    Mark this post as answer if this resolves your issue.


    Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin

    Saturday, February 23, 2013 8:08 AM
  • Hi,
     Please look at the below thread, it may help you.

    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentprevious/thread/9ba8e378-2633-4546-89ac-e63809d7f53c/

    Or

    Try ECMA script to retrieve the list data. The below help you to understand more about ECMA script.

    http://www.codeproject.com/Articles/60348/SharePoint-2010-Client-Object-Model-for-JavaScript

    If it's not helping please let us know


    Sekar - Our life is short, so help others to grow

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer


    • Edited by SekThang Saturday, February 23, 2013 8:18 AM
    Saturday, February 23, 2013 8:16 AM
  • Thanks Mohammad Nizamuddin for your time..I am creating a custom .aspx page. I want to add a drop down box which should have the the values of one particular column in a list. How do i write the ECMA script. I read one article but it was not clear.
    Saturday, February 23, 2013 1:52 PM
  • Hi SekThang..

    Thanks for your time.. In the second link where are you giving the list name and the field.And how can i bind it to the dropdown??

    Saturday, February 23, 2013 1:54 PM
  • Thanks Mohammad Nizamuddin for your time..I am creating a custom .aspx page. I want to add a drop down box which should have the the values of one particular column in a list. How do i write the ECMA script. I read one article but it was not clear.

    here is the code

    <script language="ecmascript" type="text/ecmascript"> 
            var listItem;
            var list;
            var clientContext;
            function getSetListItem() {
                this.clientContext = SP.ClientContext.get_current();
                if (this.clientContext != undefined && clientContext != null) {
                    var webSite = clientContext.get_web();
                    this.list = webSite.get_lists().getByTitle("Custom");
                    this.listItem = list.getItemById(3);
                    clientContext.load(this.listItem);
                    this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
    Function.createDelegate(this, this.OnLoadFailed));
                }
            } 
            function OnLoadSuccess(sender, args) {
                var value = this.listItem.get_item("SampleOne");
                this.listItem.set_item("SampleTwo", value);
                this.listItem.update();
                this.clientContext.load(this.listItem);
                this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess1),
    Function.createDelegate(this, this.OnLoadFailed));
            } 
            function OnLoadSuccess1(sender, args) {
                alert(this.listItem.get_item("SampleTwo"));
            } 
            function OnLoadFailed(sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            }</script>
        <input id="btnGetSetListItem" onclick="getSetListItem()" type="button" value="Get & Set List Item" />
    

    check the detail here

    http://www.c-sharpcorner.com/UploadFile/anavijai/get-and-set-the-list-item-value-in-sharepoint-2010-using-ecm/


    Mark this post as answer if this resolves your issue.


    Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin

    Saturday, February 23, 2013 4:21 PM
  • Saturday, February 23, 2013 6:44 PM