For your reference please check the below code. It is a transformation of a query repeater which has a nested query repeater which is binding data based on data received fetched from database.
<cms:queryrepeater StopProcessing="false" runat="server" ID="qrArticle" TopN="1"/>
<script runat="server">
public string sectionAliasName { get; set; }
public string articleAliasName { get; set; }
public bool isArticle { get; set; }
protected override void OnInit(EventArgs e)
{
//Check from where page description will be fetched(Article/Category)
isArticle = Convert.ToBoolean(DataBinder.Eval(this.DataItem, "IsArticlePage"));
//Add Page Title
this.Page.Title = Convert.ToString(DataBinder.Eval(this.DataItem, (isArticle == true ? "ArticleTitle" : "CategoryDisplayName" )));
//Add Keywords Meta Tag
if(!string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(this.DataItem, "MetaKeywords"))))
{
HtmlMeta keywords = new HtmlMeta();
keywords.HttpEquiv = "keywords";
keywords.Name = "keywords";
keywords.Content = Convert.ToString(DataBinder.Eval(this.DataItem, "MetaKeywords"));
this.Page.Header.Controls.Add(keywords);
}
//Add Description Meta Tag
if(!string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(this.DataItem, "MetaDescription"))))
{
HtmlMeta description = new HtmlMeta();
description.HttpEquiv = "description";
description.Name = "description";
description.Content = Convert.ToString(DataBinder.Eval(this.DataItem, "MetaDescription"));
this.Page.Header.Controls.Add(description);
}
//Bind the repeater based on parameters
sectionAliasName = Convert.ToString(DataBinder.Eval(this.DataItem, "SectionAliasName"));
articleAliasName = Convert.ToString(DataBinder.Eval(this.DataItem, (isArticle == true ? "ArticleAliasName" : "CategoryAliasName" )));
qrArticle.WhereCondition= "SectionAliasName = '" + sectionAliasName + "' AND ISNULL(ArticleAliasName, CategoryAliasName) = '" + articleAliasName + "'";
qrArticle.WhereCondition= "SectionAliasName = '" + sectionAliasName + "' AND (ArticleAliasName = '" + articleAliasName + "' OR CategoryAliasName='" + articleAliasName + "')";
qrArticle.QueryName="NCH.Transformations.GetCategoryArticles";
qrArticle.OrderBy = "IsArticlePage";
qrArticle.TransformationName= (isArticle==true ? "NCH.Transformations.GetArticleDescriptionDetail" : "NCH.Transformations.GetCategoryDescriptionDetail" );
if(qrArticle.Items.Count == 0)
{
// Show Page Not Found
//Response.Code = 404; //This line logging a 404 record on Event Log but it is
// causing a Application Exception also.
}
base.OnInit(e);
}
</script>