Hi slb2013,
Please refer below sample.
HTML
C#
<%foreach (Signal message in this.SignalData)
{%>
<div title="<%=message.SignalStrength%>" style="font-size: 2em; margin-top: 5px;"
class='<%=message.SignalStrength=="Pass"?"Green":"Red" %>'>
<%=message.Percent%>
</div>
<%} %>
<style type="text/css">
.Green { background-color: green; }
.Red { background-color: red; }
</style>
VB.Net
<% For Each message As Signal In Me.SignalData%>
<div title="<%=message.SignalStrength%>" style="font-size: 2em; margin-top: 5px;"
class='<%= If(message.SignalStrength = "Pass", "Green", "Red") %>'>
<%=message.Percent%>
</div>
<% Next%>
<style type="text/css">
.Green { background-color: green; }
.Red { background-color: red; }
</style>
Code
C#
public List<Signal> SignalData { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
SignalData = new List<Signal>()
{
new Signal{ SignalStrength="Fail",Percent=10},
new Signal{ SignalStrength="Pass",Percent=80},
};
}
}
public class Signal
{
public string SignalStrength { get; set; }
public int Percent { get; set; }
}
VB.Net
Public Property SignalData As List(Of Signal)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
SignalData = New List(Of Signal)() From {
New Signal With {
.SignalStrength = "Fail",
.Percent = 10
},
New Signal With {
.SignalStrength = "Pass",
.Percent = 80
}
}
End If
End Sub
Public Class Signal
Public Property SignalStrength As String
Public Property Percent As Integer
End Class
Screenshot