原文发布时间为:2008-07-29 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Panel1.Visible = false;
            CheckBox1.Text = "show";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int a = int.Parse(DropDownList1.SelectedValue);
        int b = int.Parse(DropDownList2.SelectedValue);
        for (int i = 0; i < a; i++)
        {
            Label lb = new Label();
            lb.ID = "lb" + i;
            lb.Text = "label" + i + "<br>";
            Panel1.Controls.Add(lb);
        }

        for (int i = 0; i < a; i++)
        {
            Label lb = new Label();
            lb.ID = "lb" + i;
            lb.Text = "label" + i + "<br>";
            PlaceHolder1.Controls.Add(lb);
        }

        for (int i = 0; i < b; i++)
        {
            TextBox tb = new TextBox();
            tb.ID = "tb" + i;
            tb.Text = "textbox" + i;
            Literal br = new Literal();
            br.Text = "<br>";
            Panel1.Controls.Add(br);
            Panel1.Controls.Add(tb);
        }

        Literal lt = new Literal();
        lt.Text = TextBox1.Text;
        Panel1.Controls.Add(lt);

    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (!CheckBox1.Checked)
        {
            CheckBox1.Text = "show";
            Panel1.Visible = false;
        }
        else
        {
            CheckBox1.Text = "hide";
            Panel1.Visible = true;
        }
    }
    private static string td(HttpContext context)
    {
        return DateTime.Now.ToString();
    }
}

-----------------------------------------------------

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
   
        for (int i = 0; i < 4; i++)//4行8列表格
        {
            TableRow tr = new TableRow();
            for (int j = 0; j < 8; j++)
            {
                TableCell tc = new TableCell();
                Label lb = new Label();
                lb.Text = i + "," + j;
                tc.Controls.Add(lb);
                tr.Controls.Add(tc);
            }

            Table1.Rows.Add(tr);
        }
      
    }
    }

net4:Panel动态添加控件及隐藏,Table动态创建表格的更多相关文章

  1. winform导入导出excel,后台动态添加控件

    思路: 导入: 1,初始化一个OpenFileDialog类 (OpenFileDialog fileDialog = new OpenFileDialog();) 2, 获取用户选择文件的后缀名(s ...

  2. VC中动态添加控件

    VC中动态添加控件 动态控件是指在需要时由Create()创建的控件,这与预先在对话框中放置的控件是不同的. 一.创建动态控件: 为了对照,我们先来看一下静态控件的创建. 放置静态控件时必须先建立一个 ...

  3. jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法

    博客分类: jquery-easyui jQueryAjax框架HTML  现象: AJAX返回的html无法做到自动渲染为EasyUI的样式.比如:class="easyui-layout ...

  4. asp.net动态添加控件学习

    看了老师的教程后,自己一点感悟记录下来: 1.在页面提交后,动态生成的控件会丢失, 但如果生成控件的代码在pageload中,就可以,原理是每次生成页面都执行生成. 2.动态按件或页面原来控件, 在页 ...

  5. WPF:理解ContentControl——动态添加控件和查找控件

    WPF:理解ContentControl--动态添加控件和查找控件 我认为WPF的核心改变之一就是控件模型发生了重要的变化,大的方面说,现在窗口中的控件(大部分)都没有独立的Hwnd了.而且控件可以通 ...

  6. Android 在布局容器中动态添加控件

    这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理. 1.addView 添加控件到布局容器 2.removeView 在布局容器中删掉 ...

  7. 怎样在不对控件类型进行硬编码的情况下在 C#vs 中动态添加控件

    文章ID: 815780 最近更新: 2004-1-12 这篇文章中的信息适用于: Microsoft Visual C# .NET 2003 标准版 Microsoft Visual C# .NET ...

  8. JQuery动态添加控件并取值

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. WPF 动态添加控件以及样式字典的引用(Style introduction)

    原文:WPF 动态添加控件以及样式字典的引用(Style introduction) 我们想要达到的结果是,绑定多个Checkbox然后我们还可以获取它是否被选中,其实很简单,我们只要找到那几个关键的 ...

随机推荐

  1. Redis错误解决:(error) MISCONF Redis is configured to save RDB snapshots

    刚开始学习使用redis数据库,在执行删除命令时,提示了我这么一个错误: 错误提示 (error) MISCONF Redis is configured to save RDB snapshots, ...

  2. vue实现与安卓、IOS交互

    方案背景 IOS用的是jsBridge插件实现调用.传参.回调的 安卓是在window挂载方法和挂载回调的 IOS实现方案 调用原生方法封装如下 function setupWebViewJavasc ...

  3. 【TCP/IP】【网络基础】网页访问流程

    引用自 <鸟哥的linux私房菜> http://cn.linux.vbird.org/linux_server/0110network_basic_1.php#ps7 那 TCP/IP ...

  4. python导出开发环境

    1.导出开发环境的依赖包 本地开发完后,再把代码给别人之前,需要 pip freeze > pip123.txt 2.其他环境安装依赖包 pip install -r pip123.txt 其他 ...

  5. 图解Disruptor框架(二):核心概念

    图解Disruptor框架(二):核心概念 概述 上一个章节简单的介绍了了下Disruptor,这节就是要好好的理清楚Disruptor中的核心的概念.并且会给出个HelloWorld的小例子. 在正 ...

  6. leetcode-5-basic

    解题思路: 设两个变量land和sink,land的值是1的数量,sink表示内部的边.result = land*4-sink*2.按行扫描得到land, 同时得到同一行中内部边的数目:然后按列扫描 ...

  7. 安装VS2010 无法打开数据文件deffactory.dat

    VS2010旗舰版可用Key: YCFHQ9DWCYDKV88T2TMHG7BHP 解压VS2010安装ISO文件,找到setup\deffactory.dat文件,用记事本打开,将里面内容清空,将以 ...

  8. LeetCode(203) Remove LinkedList Elements

    题目 Remove all elements from a linked list of integers that have value val. Example Given: 1 –> 2 ...

  9. German Collegiate Programming Contest 2015

    // Legacy Code #include <iostream> #include <cstdio> #include <cstring> #include & ...

  10. ACM-ICPC 2017 Asia Urumqi G. The Mountain

    All as we know, a mountain is a large landform that stretches above the surrounding land in a limite ...