Hi @RAVI,
You can implement it in OnItemDataBound method. The specific code is as follows:
protected void repRequests_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//Reference the Repeater Item.
RepeaterItem item = e.Item;
//Reference the Controls.
string Field2 = (item.FindControl("LP") as Label).Text;
HtmlTableRow tdValue = (HtmlTableRow)e.Item.FindControl("GraphTable");
HtmlTableCell td = (HtmlTableCell)e.Item.FindControl("tdControl");
if (Field2 == "")
{
td.ColSpan = 6;
tdValue.Cells.RemoveAt(3);
tdValue.Cells.RemoveAt(1);
tdValue.Cells.RemoveAt(0);
tdValue.Attributes.Add("style", "background-color: grey;");
}
}
}
<html>
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
table {
border-collapse: collapse;
}
table, th, td, tr {
border: 1px solid black;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="repRequests_ItemDataBound">
<HeaderTemplate>
<table class="table-hide" id="table">
<tr>
<th style="width: 110px; text-align: center; background-color: #F9E79F; font-family: Palatino Linotype; font-size: 16px;">FIELD 1</th>
<th style="width: 110px; text-align: center; background-color: #F9E79F; font-family: Palatino Linotype; font-size: 16px;">FIELD 2</th>
<th colspan="3" style="text-align: center; background-color: #F9E79F; font-family: Palatino Linotype; font-size: 16px;">FIELD 3</th>
<th style="width: 40px; text-align: center; background-color: #F9E79F; font-family: Palatino Linotype; font-size: 16px;">FIELD 4</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="GraphTable" class="hello" runat="server">
<td colspan="1">
<asp:Label ID="edtName" Font-Names="Calibri" runat="server" Font-Bold="true" Font-Size="20px"
Text='<%# Eval("Field1") %>'></asp:Label>
</td>
<td runat="server" style="text-align: center; font-family: Calibri;">
<asp:Label ID="LP" Font-Bold="true" Font-Size="20px" Width="70px" runat="server" Text='<%#Eval("Field2").ToString() == "0" ? "" : Eval("Field2", "{0:N3}")%>'></asp:Label>
</td>
<td colspan="3" id="tdControl" style="font-family: Calibri; font-size: 20px; font-weight: bold; width: 210px; text-align: center;">
<%# Eval("Field3")%>
</td>
<td style="text-align: right; font-family: Calibri;">
<asp:Label ID="LQ" Font-Bold="true" Font-Size="20px" Width="90px" runat="server" Text='<%#Eval("Field4").ToString() == "0" ? "" : Eval("Field4","{0:N3}")%>' Style="text-align: right;"></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.