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:
<div class="table-responsive"> <br/> <table class="table table-striped table-condensed"><br/> <thead><br/> <tr><br/> <th>Name</th><br/> <th>ID</th><br/> <th>Email</th><br/> </tr><br/> </thead><br/> <tbody><br/> @foreach (var row in Namespace.SQLToken("Id='" + TknParams.Id + "'")) {<br/> <tr><br/> <td>@row.SQL_COL1</td><br/> <td>@row.SQL_COL2</td><br/> <td>@row.SQL_COL3</td><br/> </tr><br/> }<br/> </tbody><br/> </table><br/></div>