11 May 2017

#6: Using MyTokens to Generate HTML Tables with dynamic content coming from SQL Database

Generate dynamic tables using My Tokens and Action Form with the exact information you want

In this video we'll show you how to use MyTokens to:
- Create a Database token that retrieves info from your SQL DB (variable number of rows)
- Create RazorScript Token to generate HTML code for rendering a bootstrap table with info coming from another database token
- pass parameters to tokens
- get QueryString data 

You'll also use Action Form and a Static Text field type to render the bootstrap table on your DNN website. This way you ca easily bring, for example, all the usernames starting with a certain letter in a dynamic table. This trick will definitely make the management of your database easier.

Here's the HTML content of the token that generates the table:

&lt;div class=&quot;table-responsive&quot;&gt;          <br/>  &lt;table class=&quot;table table-striped table-condensed&quot;&gt;<br/>    &lt;thead&gt;<br/>      &lt;tr&gt;<br/>        &lt;th&gt;Name&lt;/th&gt;<br/>        &lt;th&gt;ID&lt;/th&gt;<br/>        &lt;th&gt;Email&lt;/th&gt;<br/>       &lt;/tr&gt;<br/>    &lt;/thead&gt;<br/>    &lt;tbody&gt;<br/>    @foreach (var row in Namespace.SQLToken(&quot;Id='&quot; + TknParams.Id + &quot;'&quot;)) {<br/>      &lt;tr&gt;<br/>        &lt;td&gt;@row.SQL_COL1&lt;/td&gt;<br/>        &lt;td&gt;@row.SQL_COL2&lt;/td&gt;<br/>        &lt;td&gt;@row.SQL_COL3&lt;/td&gt;<br/>      &lt;/tr&gt;<br/>    }<br/>    &lt;/tbody&gt;<br/>  &lt;/table&gt;<br/>&lt;/div&gt;

Latest Posts from 1001

29 Aug 2019

#66: Manipulate Cookies with MyTokens

9 Aug 2019

#65: Google Maps Location Picker with markers and radius

16 Jul 2019

#64: How to Build a File Manager