//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.Globalization;usingGrapeCity.Documents.Word; namespaceDsWordWeb.Demos{// This sample demonstrates the use of multiple data sources with data templates.// It uses two simple JSON data sources, one contains a list of some popular car makes,// the other a list of various car body styles. The DOCX includes two templates that are// used to print first the list of body styles, followed by the list of car brands.// The two lists are not related to each other, demonstrating how unrelated data sources// can be used to include various data in a single data bound document.publicclassDataTplMultipleDataSrc {publicGcWordDocumentCreateDocx() {var makes = "[" +"{ \"make\": \"Toyota\" }," +"{ \"make\": \"General Motors\" }," +"{ \"make\": \"Volkswagen\" }," +"{ \"make\": \"Ford\" }," +"{ \"make\": \"BMW\" }," +"{ \"make\": \"Nissan\" }," +"{ \"make\": \"Hyundai\" }," +"{ \"make\": \"Honda\" }," +"{ \"make\": \"Mazda\" }," +"{ \"make\": \"Jaguar\" }," +"]";var bodyStyles = "[" +"{ \"style\": \"Sedan\" }," +"{ \"style\": \"Coupe\" }," +"{ \"style\": \"Hatchback\" }," +"{ \"style\": \"SUV\" }," +"{ \"style\": \"Crossover\" }," +"{ \"style\": \"Minivan\" }," +"{ \"style\": \"Pickup\" }," +"{ \"style\": \"Wagon\" }," +"]"; var doc = newGcWordDocument(); // Add the data sources: doc.DataTemplate.DataSources.Add("makes", makes); doc.DataTemplate.DataSources.Add("styles", bodyStyles); // Print the list of some car makes: doc.Body.Paragraphs.Add("Popular Car Makers", doc.Styles[BuiltInStyleId.Heading2]); doc.Body.Paragraphs.Add("{{#makes}}{{makes.make}}{{/makes}}", doc.Styles[BuiltInStyleId.ListBullet]); // Print the list of car body styles: doc.Body.Paragraphs.Add("Car Body Styles", doc.Styles[BuiltInStyleId.Heading2]); doc.Body.Paragraphs.Add("{{#styles}}{{styles.style}}{{/styles}}", doc.Styles[BuiltInStyleId.ListBullet]); doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US")); // Done:return doc; } }}