I have 2 examples, for the examples i will bind the repeater to a array of strings (demonstration purposes only)
void BindCheckboxList()
{
checkboxList.DataSource = new string[] { "RowA", "RowB", "RowC", "RowD", "RowE", "RowF", "RowG" };
checkboxList.DataBind();
}
Example 1: Create a methode in de codebehind casting the bound elements back en evaluate what ever value you'd like.
Create Methode in CodeBehind (example 1):
protected string StringDataEndsWith(object dataElement, string endsWith, string returnValue)
{
// for now an object of the type string, can be anything.
string elem = dataElement as string;
if (elem.EndsWith(endsWith))
{
return returnValue;
}
else
{
return "";
}
}
In the .aspx file (example 1):
<asp:Repeater ID="checkboxList" runat="server">
<HeaderTemplate>
<table style="padding:0px;margin:0px;">
</HeaderTemplate>
<ItemTemplate>
<%# StringDataEndsWith(Container.DataItem,"A","<tr id=\"itemRow\" runat=\"server\">") %>
<td>
<%# Container.DataItem %>
</td>
<%# StringDataEndsWith(Container.DataItem,"G","</tr>") %>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Example 2: You could use a direct cast in the .aspx file
DirectCast example (no code behind):
<asp:Repeater ID="checkboxList" runat="server">
<HeaderTemplate>
<table style="padding:0px;margin:0px;">
</HeaderTemplate>
<ItemTemplate>
<%# Convert.ToString(Container.DataItem).EndsWith("A") ? "<tr id=\"itemRow\" runat=\"server\">" : "" %>
<td>
<%# Container.DataItem %>
</td>
<%# Convert.ToString(Container.DataItem).EndsWith("G") ? "</tr>" : "" %>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I hope this is what you're looking for. Regards.