I am trying to format items in shopping cart that I display in listbox in ASP.NET using MS Visual Studio 2010. The program displays them elements of each item as a concatenated string, which works but is less elegant than I would like.
My display function within the cartItem Class is:
Public Function Display() As String Return Product.ProductName & "; " & Product.ProductID & ", (" + Quantity.ToString() & " at " & FormatCurrency(Product.UnitPrice) & " each) " End Function
I was told to "embed HTML to format your string. Add a table, trs and tds and CSS." I looked up "Embed HTML" in W3Schools and got nothing that seemed relevant. I could not find anything like this in my class textbook. When I try to insert statements like tags like and Visual Studio transforms them into and . I tried putting statements into response write as follows:
Response.Write("<html>")
Response.Write("<table>")
Response.Write("<tr>")
Response.Write("<td>")
Response.Write("<Product.ProductID>")
Response.Write("</td>")
Response.Write("<td>")
Response.Write("<Product.ProductName>")
Response.Write("</td>")
Response.Write("</tr>")
Response.Write("</table>")
However, I got an error on each line saying "Response is not declared. It may be inaccessible due to its protection level". Even if it worked, I am not certain that Response.Write would be appropriate to format something being printed inside a list box.
I could try to use another control (Detail View, Form View) to display the cart items, but I have only learned how to bind those to databases, and these items are in my cart (an object of the cartitemlist class, which is an array of cart items), not in a database.
Any help would be greatly appreciated. I need to learn this so I am not just looking for a solution to copy; I want to understand how to do this right. Thank you in advance. W