栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

GridView多层嵌套和折叠与展开

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

GridView多层嵌套和折叠与展开

Insus.NET近段时间应朋友的要求,写一个GridView多层嵌套和折叠与展开。这个功能的GridView多层嵌套没有问题,因为已经做了无限次数,但是折叠与展开的功能,却花上不少时间(网上找资料),虽找到资料可参考,还是了解明它,并修改适合自己程序使用。效果如下:

 

站点中多个页面使用,因此Insus.NET把它写在一个用户自定义控件ASCX上。

InsusMenu.ascx

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="InsusMenu.ascx.vb" Inherits="AscxControls_InsusMenu" %>                                                                     '  class="lazyload" src="https://www.mshxw.com/file/upload/202104/26/215123740.png" data-original="Image/+.gif" onclick="ShowHidde('<%#eval("Year")%>',event)" />                                                                <%# eval("Year") & "年"%>                ' >                                                                                                                                                                                                                                                                                            '  class="lazyload" src="https://www.mshxw.com/file/upload/202104/26/215123740.png" data-original="Image/+.gif" onclick="ShowHidde('<%#eval("Month")%>',event)" />                                    <%# eval("Month") & "月"%>                                    ' >                                                                                                                                                                                                                                                                                                                                                                                    ' Text='<%# eval("OldFileName").Substring(0, eval("OldFileName").LastIndexOf("."))%>' Target="_blank">                                                                                                                                                                                                                                                                                                                                                                            

 

InsusMenu.ascx.vb

imports System.Dataimports Insus.NETPartial Class AscxControls_InsusMenu    Inherits System.Web.UI.UserControl    '宣告实例    Dim objVideoLibrary As New VideoLibrary()    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load        If Not IsPostBack Then            Data_Binding()        End If    End Sub    Private Sub Data_Binding()        '从数据库获取数据,绑定在第一层的GridView        Me.GridViewYear.DataSource = objVideoLibrary.GetYear()        Me.GridViewYear.DataBind()    End Sub    '数据绑定在第二层的GridView    Protected Sub GridViewYear_RowDataBound(sender As Object, e As GridViewRowEventArgs)        Dim dvr As DataRowView = DirectCast(e.Row.DataItem, DataRowView)        If e.Row.RowType = DataControlRowType.DataRow Then            If e.Row.FindControl("GridViewMonth") IsNot Nothing Then                Dim Gv As GridView = DirectCast(e.Row.FindControl("GridViewMonth"), GridView)                objVideoLibrary.Year = ConvertData.ToSmallInt(dvr("Year"))                Gv.DataSource = objVideoLibrary.GetMonthByYear()                Gv.DataBind()            End If        End If    End Sub    '数据绑定在第三层的GridView    Protected Sub GridViewMonth_RowDataBound(sender As Object, e As GridViewRowEventArgs)        Dim dvr As DataRowView = DirectCast(e.Row.DataItem, DataRowView)        If e.Row.RowType = DataControlRowType.DataRow Then            If e.Row.FindControl("GridViewVideoFile") IsNot Nothing Then                Dim Gv As GridView = DirectCast(e.Row.FindControl("GridViewVideoFile"), GridView)                objVideoLibrary.Year = ConvertData.ToSmallInt(dvr("Year"))                objVideoLibrary.Month = ConvertData.ToTinyInt(dvr("Month"))                Gv.DataSource = objVideoLibrary.GetByYearAndMonth()                Gv.DataBind()            End If        End If    End SubEnd Class

  

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/246333.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号