zoukankan      html  css  js  c++  java
  • [置顶] Datalist嵌套datalist,页面传值,加密,数据绑定

     <asp:DataList ID="dlMajor" runat="server" CssClass="dllist" OnItemDataBound="dlMajor_ItemDataBound">
                <ItemTemplate>
                    <div class="div_major">
                        <%#Eval("major_name")%>
                        <asp:HiddenField ID="hf_major" runat="server" Value='<%#Eval("major_url") %>'></asp:HiddenField>
                    </div>
                    <asp:DataList ID="dlClass" runat="server" CssClass="dllist" OnItemDataBound="dlClass_ItemDataBound">
                        <ItemTemplate>
                            <div class="div_class">
                                <%#Eval("class_name")%>
                                <asp:HiddenField ID="hf_class" runat="server" Value='<%#Eval("class_url") %>'></asp:HiddenField>
                            </div>
                            <ul>
                                <asp:DataList ID="dlStudent" runat="server" CssClass="dllist" OnItemDataBound="dlClass_ItemDataBound">
                                    <ItemTemplate>
                                        <li>
                                            <div class="num left">
                                                <%#Eval("id")%>、</div>
                                        
                                                <%#new checkFiles.common.utils().GetInfo(Eval("student_url").ToString())%>
                                            </div>
                                        </li>
                                    </ItemTemplate>
                                </asp:DataList>
                            </ul>
                        </ItemTemplate>
                    </asp:DataList>
                </ItemTemplate>
                <FooterTemplate>
                    <%--    <%if(dlMajor.Items.Count<=0) %>--%>
                </FooterTemplate>
            </asp:DataList>



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using checkFiles.common;
    
    namespace checkFiles
    {
        public partial class center : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string path = "";
                if (Request.QueryString["path"] != null && Request.QueryString["path"].ToString().Trim().Length > 0)
                {
    
                    path = Server.HtmlDecode((Request.QueryString["path"].ToString().Trim()));
                    
                }
              
                if (!IsPostBack)
                {
                    utils util = new utils();
                    dlMajor.DataSource = util.GetMajorName(path);
                    dlMajor.DataBind();
                    if (dlMajor.Items.Count <= 0)
                    {
                        this.Panel1.Visible = true;
                    }
                    else
                    {
                        this.Panel1.Visible = false;
    
                    }
                }
    
            }
            protected void dlMajor_ItemDataBound(object sender, DataListItemEventArgs e)
            {
    
                utils util = new utils();
    
                HiddenField hf_major = (HiddenField)e.Item.FindControl("hf_major");
                if (hf_major != null)
                {
    
                    string path = hf_major.Value.ToString();
                    if (e.Item.ItemType == ListItemType.EditItem || e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                    {
                        DataList dlClass = (DataList)e.Item.FindControl("dlClass");
                        dlClass.DataSource = util.GetClassName(path);
                        dlClass.DataBind();
                    }
                  
                } 
            }
            protected void dlClass_ItemDataBound(object sender, DataListItemEventArgs e)
            {
    
                utils util = new utils();
    
                HiddenField hf_class = (HiddenField)e.Item.FindControl("hf_class");
                if (hf_class != null)
                {
    
                    string path = hf_class.Value.ToString();
                    if (e.Item.ItemType == ListItemType.EditItem || e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                    {
                        DataList dlStudent = (DataList)e.Item.FindControl("dlStudent");
                        dlStudent.DataSource = util.GetStudentName(path);
                        dlStudent.DataBind();
                    }
                }
            }
        }
    }


  • 相关阅读:
    背景颜色的渐变设置--实现丰富多彩的背景效果
    CSS-sprit 雪碧图
    背景图片的相关设置
    关于阿里云图标的使用 iconfont
    HTML四种定位-粘滞定位
    HTML四种定位-固定定位
    HTML四种定位-绝对定位
    HTML四种常见的定位-相对定位
    水平居中
    CentOS8更换国内镜像源
  • 原文地址:https://www.cnblogs.com/wsq724439564/p/3258225.html
Copyright © 2011-2022 走看看