Web form issue

Scott Huang 3,511 Reputation points
2023-01-20T07:49:30.2666667+00:00

Hi,

I get "undefined" unexpectedly to the column/field below, while there is the proper row value returned from the table. What is the reason?

html += "<td >货币</td><td style='font-weight: bold;Font-size:16px;Font-family:標楷體;color: #D93256;' colspan=2 >" + Currency.Currency_Code + "</td>";

Microsoft 365 and Office | Development | Office JavaScript API
Developer technologies | ASP.NET Core | Other

4 answers

Sort by: Most helpful
  1. MesseAcess 0 Reputation points
    2023-01-28T09:01:17.8066667+00:00

    Hi,

    I also get "undefined" error on my Foe Calculator site unexpectedly to the column/field below, while there is the proper row value returned from the table. What is the reason?

    Was this answer helpful?


  2. AgaveJoe 31,361 Reputation points
    2023-01-24T16:06:28.92+00:00

    The community has explained what JavaScript "undefined" means, provided troubleshooting steps, and sample code to troubleshoot. Unfortunately, you've provided no feedback whatsoever. We have no idea if you tried debugging your code. Can you at least try the troubleshooting steps and tell us the results?

    Was this answer helpful?


  3. QiYou-MSFT 4,341 Reputation points Microsoft External Staff
    2023-01-23T02:16:10.3166667+00:00

    Hi @Scott Huang

    First I studied your code ideas based on your previous cases. Your idea is to read out Currency_code data from the database and save it in a datarow. Then you use dataRow.Field ("<string>Currency_code") to save the "Currency_code" in the datarow as a variable of type string. Finally, it is saved for use in the Currency class.

    using (SqlCommand sqlCmd = new SqlCommand("SELECT ...", sqlConn))
    
    Currency_code = dataRow.Field<string>("Currency_code"),
    

    The Field method on the DataRow class casts a DataTable cell to a specific type.

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


  4. QiYou-MSFT 4,341 Reputation points Microsoft External Staff
    2023-01-20T09:15:57.9833333+00:00

    Hi @Scott Huang

    You can see how the value of your variable changes in VS debug. In general, undefined variables cannot be used. Or it is also possible that it is already defined in aspx.

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.