literalControl

表示 HTML 元素、文本和 ASP.NET 页中不需要在服务器上处理的任何字符串。
用法:new literalcontrol("李江软件");
例如:(点击按纽button2根据DropDownList1和DropDownList2选择的数字动态增加表格Table1的行和列)
protected void Button2_Click(object sender, EventArgs e)
    {
        int r = int.Parse(this.DropDownList1.SelectedValue);
        int c = int.Parse(this.DropDownList2.SelectedValue);      
        for (int i = 0; i < r; i++)
        {
            TableRow hang = new TableRow();     
            //此处省去对列的判断
            TableCell lie = new TableCell();
           // lie.Text = "55555"; //这里其实和下面lie.Controls.Add(new LiteralControl("55555"));功能是一样的。
            lie.Controls.Add(new LiteralControl("55555"));
            hang.Cells.Add(lie);
            Table1.Rows.Add(hang);
        }
    }

posted @ 2010-03-28 10:59  帅得左右为难  阅读(115)  评论(0)    收藏  举报