Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

Show a list of customer orders

Scroll Prev Next More

 

Show a list of all orders placed by the current customer on the Order Edit page.

 

Insert C#/VB.NET code snippet on the Page Designer screen:

 

dynamic tblOrders = GlobalVars.dal.Table("Orders");
var rs = tblOrders.Query(String.Format("OrderID={0}", MVCFunctions.postvalue("editid1")), "");
var data = CommonFunctions.db_fetch_array(rs);
var CustomerID = data["customerid"];
MVCFunctions.Echo(String.Format("Orders placed by {0} <br>", CustomerID));
var rsOrders = tblOrders.Query(String.Format("customerid='{0}'", CustomerID), "");
 
while(data = CommonFunctions.db_fetch_array(rsOrders))
{
 MVCFunctions.Echo(
  String.Format("<a target=_blank href='{0}'>{1}</a> {2}<br>",
       MVCFunctions.GetTableLink("Orders", "edit", String.Format("editid1={0}", data["OrderID"])),
       data["OrderID"], data["OrderDate"]));
}

 

 

See also:

Database API

Master-details relationship between tables