Code
<script type="text/javascript">
var selectRowUrl = "";
var selectRowID = "";
/* Grid切换color 用在第一列为 checkbox */
function GridViewSwitchColor(GridViewId, NormalColor, AlterColor, HoverColor, SelectColor) {
if (document.getElementById(GridViewId) == null)
return;
selectRowUrl = "";
selectRowID = "";
var AllRows = document.getElementById(GridViewId).getElementsByTagName("tr");
if (AllRows == null)
return
for (var i = 1; i < AllRows.length; i++) {
AllRows[i].style.background = i % 2 == 0 ? NormalColor : AlterColor;
if (HoverColor != "") {
AllRows[i].onmouseover = function() {
if (!this.selected) this.style.background = HoverColor;
}
if (i % 2 == 0) {
AllRows[i].onmouseout = function() { if (!this.selected) this.style.background = NormalColor; }
}
else {
AllRows[i].onmouseout = function() { if (!this.selected) this.style.background = AlterColor; }
}
}
if (SelectColor != "") {
AllRows[i].onclick = function() {
this.style.background = this.style.background == SelectColor ? HoverColor : SelectColor;
this.selected = !this.selected;
if (this.childNodes[0].childNodes[0].type != undefined && this.childNodes[0].childNodes[0].type == "checkbox") {
this.childNodes[0].childNodes[0].checked = this.selected;
if (this.selected) {
if (selectRowUrl == "") {
if (this.tagName == "TR" && this.attributes.item("ondblclick") != undefined) {
selectRowUrl = this.attributes.item("ondblclick").nodeValue;
if (selectRowUrl != null) {
selectRowUrl = selectRowUrl.replace("return false;", "");
this.style.background = "#9EBCF5";
selectRowID = this.uniqueID
}
}
}
}
else {
if (selectRowUrl != "" && selectRowID == this.uniqueID) {
selectRowUrl = "";
selectRowID = "";
this.style.background = "";
}
}
}
}
}
}
}
</script>
<asp:TreeListView ID="tlv" runat="server"
NodeColumnIndex="1" EnableViewState="true"
ParentKey="ParentID" Width="100%" ColumnKey="ID" SortKey="SortOrder"
AutoGenerateColumns="False" ExpendDepth="2"
>
<Columns>
<asp:BoundField DataField="ID" />
<asp:BoundField DataField="name" />
<asp:BoundField DataField="description" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlEdit" runat="server">编辑</asp:HyperLink>
<asp:LinkButton ID="lbDelete" runat="server">删除</asp:LinkButton>
<asp:HyperLink ID="hlMovieRel" Visible='<%# Eval("IsChild") %>' runat="server">分类产品维护</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:TreeListView>
<script type="text/javascript">
try { GridViewSwitchColor("tlm", "#FFFFFF", "#F2F6FB", "FFDD66", "#FFFFFF"); } catch (e) { }
</script>
<script type="text/javascript">
var selectRowUrl = "";
var selectRowID = "";
/* Grid切换color 用在第一列为 checkbox */
function GridViewSwitchColor(GridViewId, NormalColor, AlterColor, HoverColor, SelectColor) {
if (document.getElementById(GridViewId) == null)
return;
selectRowUrl = "";
selectRowID = "";
var AllRows = document.getElementById(GridViewId).getElementsByTagName("tr");
if (AllRows == null)
return
for (var i = 1; i < AllRows.length; i++) {
AllRows[i].style.background = i % 2 == 0 ? NormalColor : AlterColor;
if (HoverColor != "") {
AllRows[i].onmouseover = function() {
if (!this.selected) this.style.background = HoverColor;
}
if (i % 2 == 0) {
AllRows[i].onmouseout = function() { if (!this.selected) this.style.background = NormalColor; }
}
else {
AllRows[i].onmouseout = function() { if (!this.selected) this.style.background = AlterColor; }
}
}
if (SelectColor != "") {
AllRows[i].onclick = function() {
this.style.background = this.style.background == SelectColor ? HoverColor : SelectColor;
this.selected = !this.selected;
if (this.childNodes[0].childNodes[0].type != undefined && this.childNodes[0].childNodes[0].type == "checkbox") {
this.childNodes[0].childNodes[0].checked = this.selected;
if (this.selected) {
if (selectRowUrl == "") {
if (this.tagName == "TR" && this.attributes.item("ondblclick") != undefined) {
selectRowUrl = this.attributes.item("ondblclick").nodeValue;
if (selectRowUrl != null) {
selectRowUrl = selectRowUrl.replace("return false;", "");
this.style.background = "#9EBCF5";
selectRowID = this.uniqueID
}
}
}
}
else {
if (selectRowUrl != "" && selectRowID == this.uniqueID) {
selectRowUrl = "";
selectRowID = "";
this.style.background = "";
}
}
}
}
}
}
}
</script>
<asp:TreeListView ID="tlv" runat="server"
NodeColumnIndex="1" EnableViewState="true"
ParentKey="ParentID" Width="100%" ColumnKey="ID" SortKey="SortOrder"
AutoGenerateColumns="False" ExpendDepth="2"
>
<Columns>
<asp:BoundField DataField="ID" />
<asp:BoundField DataField="name" />
<asp:BoundField DataField="description" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlEdit" runat="server">编辑</asp:HyperLink>
<asp:LinkButton ID="lbDelete" runat="server">删除</asp:LinkButton>
<asp:HyperLink ID="hlMovieRel" Visible='<%# Eval("IsChild") %>' runat="server">分类产品维护</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:TreeListView>
<script type="text/javascript">
try { GridViewSwitchColor("tlm", "#FFFFFF", "#F2F6FB", "FFDD66", "#FFFFFF"); } catch (e) { }
</script>
Code
private void BindTreeListView()
{
TreeListView.TreeImageFolder = "../images/Tree/";
this.tlv.RootNodeFlag = 0;
this.tlv.DataSource = cm.GetAllList();
this.tlv.DataBind();
}
private void BindTreeListView()
{
TreeListView.TreeImageFolder = "../images/Tree/";
this.tlv.RootNodeFlag = 0;
this.tlv.DataSource = cm.GetAllList();
this.tlv.DataBind();
}