I have a procedure in C# code-behind that reads values from several fields in a database and puts each into its own 1 dimensional array. Now I need to take those values and pass them to the client side so that I can print them out on a thermal printer.
In my code-behind I have:
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++;
}
In my JavaScript I have:
var getLocation = '<%= Location %>'
var getPayType = '<%= PayType %>'
var getPayQuantity = '<%= PayQuntity %>'
var getAmount = '<%= PayAmount %>'
I want to be able to do loop through the three arrays in my printer setup to establish line items.
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"});
}
I can print out Location but the value of each of my arrays shows as 'System.String[]. Most topics I have read on this are confusing showing the array being loaded as 'var myarray("apples", "oranges", "peaches"). I have also seen topics talking about serializing the array but that is not clear either. Any examples of how to accomplish what I have shown would be greatly appreciated. Thanks Charles