none
Loading into a text box using Javascript from data array created using Linq to SQL RRS feed

  • Question

  • I have a program where i load data through a web service from a linq to sql connection.  The code is in Javascript which, if i am loading the data directly into a HTML table it is fine but i now want to put the data into text boxes for each field.  The data is only ever a single record.  I am using the document.getElementByID method to put data in the text boxes.  If i hard code the text e.g. "Fred" then it works but i can't get the data out of the data array.  Can anyone tell me how?

    <script type="text/javascript">
            var SuppView;
    
            function pageLoad() {
                $addHandler($get("DropDownList1"), "change", showSupplier);
            }
    
            function showSupplier() {
                var SuppIDs = $get("DropDownList1").value;
                Client.StockService.GetSuppFromID(SuppIDs, showSupplierComplete);
            }
    
            function showSupplierComplete(data) {
                document.getElementById("txtSuppName").value = ?????? ;
            }
    
        </script>

    
    
    
    Wednesday, September 5, 2012 3:20 PM

Answers

  • Hi SquadShun,

    Welcome to MSDN Forum.

    I'm not sure what's the result you got from Linq to SQL. If the sequence only contains one record, you can use SingleOrDefault method to get the exact object, then you can assign this object's property to your HTML element.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 6, 2012 2:03 AM
    Moderator