GridView multi-layer nesting, collapse and expansion, and gridview multi-layer nesting

Source: Internet
Author: User

GridView multi-layer nesting, collapse and expansion, and gridview multi-layer nesting

Insus. NET should be a friend's request in the near future to write a GridView multi-layer nesting, folding and expansion. There is no problem with the multi-layer nesting of the GridView function because it has already been used for an unlimited number of times, but the function of folding and expansion takes a lot of time (searching for information on the internet). Although you can find the information for reference, understand it and modify it to suit your program. The effect is as follows:

 

The website uses multiple pages, so Insus. NET writes it on a user-defined control ASCX.

InsusMenu. ascx <% @ Control Language = "VB" AutoEventWireup = "false" CodeFile = "InsusMenu. ascx. vb" Inherits = "AscxControls_InsusMenu" %> <! -- Collapse and expand the Javascript section --> <script type = "text/javascript" language = "javascript"> function ShowHidde (sid, evt) {evt = evt | window. event; var target = evt.tar get | evt. srcElement; var objDiv = document. getElementById ("div" + sid); objDiv. style. display = objDiv. style. display = "none "? "Block": "none"; target. title = objDiv. style. display = "none "? "Show": "Hide"; var imgid = 'img '+ sid; document. getElementById (imgid). src = objDiv. style. display = "none "? "Image/developer.gif": "Image/-.gif" ;}</script> <! -- The first layer --> <asp: gridView ID = "GridViewYear" runat = "server" Width = "100%" AutoGenerateColumns = "False" OnRowDataBound = "GridViewYear_RowDataBound" ShowHeader = "false" BorderWidth = "0"> <Columns> <asp: templateField> <ItemStyle BorderWidth = "0" Height = "25"/> <ItemTemplate> <! -- Bind Eval ("Year") to obtain a unique ID. If your record has a primary key, the field name that can be bound to the primary key -->  '> InsusMenu. ascx. vbImports System. dataImports Insus. NETPartial Class AscxControls_InsusMenu Inherits System. web. UI. userControl 'declare instance 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 () 'gets data from the database and binds it to the GridView Me at the first layer. gridViewYear. dataSource = objVideoLibrary. getYear () Me. gridViewYear. dataBind () End Sub 'data is bound to the 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 Sub 'data is bound to the 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 SubEnd Class

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.