Displaying custom data

Sometimes you may want to display the data stored in the database within your custom table. This brief article describes the way how you are able to achieve this using the portal engine development model without need to use any additional development tool.
Sometimes you might need to display the data stored in the custom tables. In this case the Kentico CMS provide you with the web parts supporting the custom queries- the QueryRepeater, the QueryDataList and the QueryDataGrid (version 6 also includes: QueryRepeaterWithEffect and QueryUniView). Using these web parts you are able to display any data, especially the data that aren't related to any document type. Let's say you want to display all the newsletter issues with some additional data.

First you would need to create the custom query. You could create it through the 'Site manager-> Development-> Document types-> <selectDocumentType>-> Edit-> Queries-> New Query'. Please note it really doesn't matter which document type you choose for your query. The simple query could look like:

SELECT * FROM Newsletter_NewsletterIssue

Then you should create the transformation used to display the obtained data. Please note the exact column names should be used for evaluating the content. You should use the same column names as specified in the database. The transformation could then look like:

<b>Issue subject: <%# Eval("IssueSubject") %></b><br/>
Number of sent e-mails: <%# Eval("IssueSentEmails") %><br/>
Number of unsubsribed users: <%# Eval("IssueUnsubscribed") %><br/>
Finally you can add the web part with custom query to your page. Select the custom query defined above, use the transformation specified earlier and display the content. The result could be the following:
If you want to manage custom tables in CMSDesk, please consider the Custom tables module.

See also: Web parts documentation for version 6

Applies to: Kentico CMS all versions
Share this article on   LinkedIn Google+

Jaroslav Kordula

Jaroslav joined Kentico in 2006. He is a Technical Leader in a development team whose main focus is content management. This includes Documents, Custom tables, Media libraries and other related functionality.