The HTML5 based editor and template designer is typically used to create mail merge templates in web applications.

The data source for the Reports ribbon tab can be pre-loaded in the view using the LoadDataSet method. Using this data source, the available merge field and merge block drop-down lists are populated.

The following code shows how to create a DataSet in the controller that is stored in the ViewBag:

public ActionResult Index()
DataSet ds = new DataSet();
// create the outer table that has a relation
// to the child table "product"
DataTable dtReport = new DataTable("report");
dtReport.Rows.Add(new object[] { 0 });
// create a table "products"
DataTable dtProduct = new DataTable("product");
dtProduct.Columns.Add(new DataColumn("report_id",
dtProduct.Columns.Add(new DataColumn("Product_ID",
dtProduct.Columns.Add(new DataColumn("Product_Name",
dtProduct.Columns.Add(new DataColumn("product_Price",
dtProduct.Rows.Add(new object[] { 0, 1, "Product 1", 1000 });
dtProduct.Rows.Add(new object[] { 0, 2, "Product 2", 2000 });
dtProduct.Rows.Add(new object[] { 0, 3, "Product 3", 3000 });
// create the relation
ds.Relations.Add(new DataRelation("relation1",
dtProduct.Columns["report_id"], false));
// fill the ViewBag and return the view
ViewBag.dataSet = ds;
return View();
view raw HomeController.cs hosted with ❤ by GitHub

In the view, the LoadDataSet method is used to load the stored DataSet from the ViewBag.

view raw Index.cshtml hosted with ❤ by GitHub

The drop-down lists are now pre-populated with the available merge fields and merge blocks:

MVC: Loading a DataSet from the ViewBag