zoukankan      html  css  js  c++  java
  • 如何在面板中创建动态内容的经典代码

    //占位符控件    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;
            }

  • 相关阅读:
    嵌入式 VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)
    嵌入式 hi3518x平台h264+g711a封装mp4代码demo
    嵌入式 十个最值得阅读学习的C开源项目代码
    嵌入式 arm平台ping域名指定ip小结
    嵌入式 busybox自带的tftp、telnet、ftp服务器
    嵌入式 hi3518平台检测网线是否插上
    嵌入式 hi3518平台获取网络环境中的ip、netmask、broadcast等信息
    jdbcUrl is required with driverClassName错误解决
    class path resource [processes/] cannot be resolved to URL because it does not exist
    SpringBoot2.0--- 多数据源配置
  • 原文地址:https://www.cnblogs.com/ahuang1118/p/172520.html
Copyright © 2011-2022 走看看