ListView with itemtemplate- Highlight selected row
-
Hi, I have listview with itemtemplates. so listview's each row is in the format as In design it looks similar to as asp:ListView ID="ListviewSelectedBaseLayers" runat="server" DataKeyNames="Layer_ID"> .. .. Now when I click on checkbox or the label, listview's selected row does not hilight. How to achieve this? I tried by toggling the colour of the table covering table row by putting onclick javascript for the label. Did not find enough information on this ? So if anybody give some tips will really help. thanks vijay
-
Hi, I have listview with itemtemplates. so listview's each row is in the format as In design it looks similar to as asp:ListView ID="ListviewSelectedBaseLayers" runat="server" DataKeyNames="Layer_ID"> .. .. Now when I click on checkbox or the label, listview's selected row does not hilight. How to achieve this? I tried by toggling the colour of the table covering table row by putting onclick javascript for the label. Did not find enough information on this ? So if anybody give some tips will really help. thanks vijay
You can do it through the onclick event of the tr element. Here's a simple snippet of what you might want to do.
<tr style="border:solid 1px Black;" onclick="ToggleColor(event);">
And on the function
function ToggleColor(ev) {
var tar;
//IE and Firefox treats the event caller differently. This snippet is to make sure
//that what we are selecting is the right element before setting its background color.
if (ev.srcElement != null) {
tar = ev.srcElement.parentElement;
}
else {
tar = ev.currentTarget;
}if (tar.bgColor == "#eeeeee") { tar.bgColor = "#ffffff"; } else { tar.bgColor = "#eeeeee"; };
}
Hope this helps.
Walter
-
You can do it through the onclick event of the tr element. Here's a simple snippet of what you might want to do.
<tr style="border:solid 1px Black;" onclick="ToggleColor(event);">
And on the function
function ToggleColor(ev) {
var tar;
//IE and Firefox treats the event caller differently. This snippet is to make sure
//that what we are selecting is the right element before setting its background color.
if (ev.srcElement != null) {
tar = ev.srcElement.parentElement;
}
else {
tar = ev.currentTarget;
}if (tar.bgColor == "#eeeeee") { tar.bgColor = "#ffffff"; } else { tar.bgColor = "#eeeeee"; };
}
Hope this helps.
Walter