Show Alternate Color of Header in Data List Control

Show Alternate Color of Header in Data List Control

Follow two steps for implementation

Step 1: Add below section to Head Tag

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>
$(document).ready(function () {
AddColorToHeaderStrip();

});

function AddColorToHeaderStrip() {
var allstrip = $(“div[id^=headerStrip_]”);
var i = 0;
$.each(allstrip, function () {
if (i == 0) {
i++;
$(this).attr(“class”, “Hoc_top”);
}
else if (i == 1) {
i++;
$(this).attr(“class”, “Diem_top”);
}
else if (i == 2) {
i++;
$(this).attr(“class”, “Infinitium_top”);

}
else {
i++;
$(this).attr(“class”, “Gratis_top”);
i = 0;
}
});

}
</script>
Step 2: Add below section to Design Page or Aspx Page

<asp:DataList ID=”GridViewSubscriptOption” runat=”server” RepeatColumns=”4″
CellPadding=”0″ CellSpacing=”0″ RepeatLayout=”Flow” >
<ItemTemplate >
<div id=”headerStrip_<%# Eval(“ID”) %>”>
<h1>
<asp:Label ID=”LabelName” runat=”server” Text='<%# Eval(“Name”) %>’></asp:Label></h1>
</div>

</ItemTemplate>
</asp:DataList>

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply