Web form issue

Peter_1985 2,526 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>";

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,277 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
875 questions
{count} votes

4 answers

Sort by: Most helpful
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2023-01-20T09:15:57.9833333+00:00

    Hi @Peter_1985

    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.


  2. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2023-01-23T02:16:10.3166667+00:00

    Hi @Peter_1985

    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.


  3. AgaveJoe 26,136 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?


  4. 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?