• 如何在面板中创建动态内容的经典代码


    //占位符控件    protected System.Web.UI.WebControls.PlaceHolder phPlaces;
    private void InitPlaces()
            
    {
                LiteralControl lbl;
                
    string msg;
                LinkButton btn;

                phPlaces.Controls.Clear();
                msg 
    = "Type: {0}, Place: {1}. From {2}/{3} to {4}/{5}. Description: {6}.";

                
    foreach (DataRow row in ds.Tables["Existing"].Rows)
                
    {
                    lbl 
    = new LiteralControl();
                    
                    
    // Format the msg variable with values in the row
                    lbl.Text = string.Format(msg, row["Type"], row["Place"], 
                        row[
    "MonthIn"], row["YearIn"], 
                        row[
    "MonthOut"], row["YearOut"], row["Name"]);
                    
                    btn 
    = new LinkButton();

                    
    // Assign a unique ID to the control
                    btn.ID = row["LapseID"].ToString().Replace("-"string.Empty);
                    btn.Text 
    = "Delete";
                    
                    
    // Pass the LapseID when the link is clicked
                    btn.CommandArgument = row["LapseID"].ToString();

                    
    // Attach the handler to the event
                    btn.Command += new CommandEventHandler(OnDeletePlace);

                    
    // Add the controls to the placeholder
                    phPlaces.Controls.Add(lbl);
                    phPlaces.Controls.Add(btn);
                    phPlaces.Controls.Add(
    new LiteralControl("<br>"));
                }

                
    // Hide the panel if there are no rows
                if (ds.Tables["Existing"].Rows.Count > 0)
                    pnlExisting.Visible 
    = true;
                
    else 
                    pnlExisting.Visible 
    = false;
            }

  • 相关阅读:
    Spring-四种常用注解
    Spring-IOC
    Spring-bean 的管理细节
    Android R.java文件
    MySQL | windows10 安装MySQL : 无法将“mysql”项识别为 cmdlet、函数、脚本....
    统计知识 | 决定系数 R方、调整后的R方、F值
    R | R语言表达式中常用的符号
    回归分析 | R语言回归算法、模型诊断
    R | 探索性数据分析 EDA
    R语言基础 | 概率分布的表示方法
  • 原文地址:https://www.cnblogs.com/ahuang1118/p/172520.html
Copyright © 2020-2023  润新知