This project is read-only.


Feb 5, 2011 at 6:57 AM

how can i do ConditionalFormatting ?

meaning change color of row accordng to data value?

Feb 5, 2011 at 12:05 PM

What kind of display are you building, an html table?

Just define two css classes, odd and even, and apply them alternatively to your table rows. You could also do that client-side with jQuery, like in this example (not about XsltDb, but technique is the same).


Feb 5, 2011 at 4:51 PM

As far as I remember you are using RadGrid. So you must use ASP.NET tools to do that. You have to

  • Create an ASP.NET user control that does what your need,
  • Add this control to DNN page using XsltDb.

Here is an example: List of users where current user is highlighted.

1. Creating UserControl. Here we create a simple list of user and add public property HighlightedLogin to assign a username to be highlighted. (To run this sample you maybe need to change prefix in dnn_Users table.)

<%@ Control Language="C#" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<asp:SqlDataSource ID="ds" runat="server"
    SelectCommand="select UserName, DisplayName, Email from dnn_Users"
    ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" />

<telerik:RadGrid runat="server" DataSourceID="ds" OnItemDataBound="ProcessColors" />
<script runat="server">

    // This is a property that will be set in XsltDb configuration
    // Actually, we tell grid what row(s) should be highlighted.
    private string login;
    public string HighlightedLogin
        set { login = value; }

    public void ProcessColors(object sender, GridItemEventArgs args)
        GridDataItem item = args.Item as GridDataItem;
        if (item != null && item["UserName"].Text == login)
                item.BackColor = Color.Yellow;


The code above should be put into ~/Controls/SomeGrid.ascx (or any other ascx file under DNN root folder)

2. Creating XsltDb configuration. Just put module on page and assign current user to HighlightedLogin property

<xsl:text disable-output-escaping="yes"><![CDATA[
<%@ Register TagName="Grid" TagPrefix="my" Src="~/Controls/SomeGrid.ascx" %>

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik" xmlns:my="my">
  <my:Grid runat="server" HighlightedLogin="{mdo:dnn('U.Username')}" />

This is common technique when using ASP.NET libraries as Telerik.

Another way is displaying data without using ASP.NET by creating pure HTML table.

<xsl:variable name="users" select="mdo:sql('
  select Username, DisplayName, Email
  from {databaseOwner}[{objectQualifier}Users]', 'user')"/>                         

<style type="text/css">
  .user-list { border-collapse:collapse; }
  .user-list td { border:1px solid #aaa; }
  .user-list thead { font-weight:bold; }
<table class="user-list">
  <td>User Name</td>
  <td>Display Name</td>
<xsl:for-each select="$users//user">
  <xsl:if test="Username = mdo:dnn('U.Username')">
    <xsl:attribute name="style">background-color:Yellow</xsl:attribute>