【发布时间】:2017-05-11 05:28:06
【问题描述】:
我在 C# 代码隐藏中有一个过程,它从数据库中的多个字段读取值并将每个字段放入自己的一维数组中。现在我需要获取这些值并将它们传递给客户端,以便我可以在热敏打印机上打印出来。
在我的代码隐藏中,我有:
Public String[] PayType = new string[DetailLines];
Public String[] PayQuantity = new string[DetailLines];
Public String[] PayAmount = new string[DetailLines]'
Public String Location;
Protected Void PrintReceipt()
*Miscellaneous code down to this point not shown.*
**DetailLines comes from record count**
Location = "CA";
PayType = new string[DetailLines];
PayQuantity = new string[DetailLines];
PayAmount = new string[DetailLines]'
foreach (DataRow row in dtPOSdetail.Rows)
{
PayType[LineNumber] = row["fldDescription"].ToString();
PayQuantity[LineNumber] = row["fldQuantity"].ToString();
PayAmount[LineNumber] = string.Format("{0:C}",
Decimal.Parse(row["fldAmount"].ToString()));
LineNumber++;
}
在我的 JavaScript 中,我有:
var getLocation = '<%= Location %>'
var getPayType = '<%= PayType %>'
var getPayQuantity = '<%= PayQuntity %>'
var getAmount = '<%= PayAmount %>'
我希望能够在我的打印机设置中循环遍历三个数组以建立行项目。
request += builder.createTextElement({ data: "Location: " + GetLocation + "\\n" });
for (int i = 0; i < PayType.Length; i++)
{
request += builder.createTextElement({ data: PayType[i] + "\\x9" + PayQuantity[i] + "\\x9" + " " + PayAmount[i] + "\\n"});
}
我可以打印出位置,但我的每个数组的值都显示为“System.String[]。我读过的大多数主题都令人困惑,因为数组被加载为 'var myarray("apples", "oranges", "peaches")。我还看到有关序列化数组的主题,但这也不清楚。 任何有关如何完成我所展示的内容的示例将不胜感激。 谢谢 查尔斯
【问题讨论】:
标签: javascript c# arrays