Hi iammann,
I have created sample code which fullfill requirement.
HTML
<div>
<asp:DataList ID="dlplot" runat="server" OnItemDataBound="dlplot_ItemDataBound">
<HeaderTemplate>
<table style="border-width: 1px; border-color: black; border-style: solid">
<tr>
<th>
</th>
<th>
Plot No
<hr />
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblStatus" Text='<%#Eval("Status")%>' Visible="false" runat="server" />
</td>
<td>
<asp:Label ID="lblPlot" Text='<%#Eval("PlotNo")%>' runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
</div>
<div>
<style type="text/css">
.hold
{
color: green;
font: white;
}
.available
{
color: blue;
font: white;
}
.booked
{
color: red;
font: white;
}
</style>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("PlotNo", typeof(string));
dt.Columns.Add("Status", typeof(int));
dt.Rows.Add("Plot2044", 0);
dt.Rows.Add("Plot241", 1);
dt.Rows.Add("Plot989", 2);
dt.Rows.Add("Plot332", 2);
dt.Rows.Add("Plot992", 1);
dlplot.DataSource = dt;
dlplot.DataBind();
}
protected void dlplot_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string Status = (e.Item.FindControl("lblStatus") as Label).Text;
switch (Status)
{
case "0":
(e.Item.FindControl("lblPlot") as Label).CssClass = "hold";
break;
case "1":
(e.Item.FindControl("lblPlot") as Label).CssClass = "available";
break;
case "2":
(e.Item.FindControl("lblPlot") as Label).CssClass = "booked";
break;
}
}
}
Screenshot
I hope works for you.