是蠻直接的,不需要再透過JQUERY之類的,像PHP那樣需要再透過JQUERY產生
說明開始
F001.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="F001.aspx.cs" Inherits="F001" %>
F001.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class F001 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
TableRow row = new TableRow();
TableCell cell1 = new TableCell();
cell1.Text = "表格第一列";
row.Cells.Add(cell1);
TableCell cell2 = new TableCell();
cell2.Text = "表格第二列";
//cell2.Font.Size = FontUnit.Large; //設定文字尺寸
cell2.ForeColor = System.Drawing.Color.Blue; //設定文字顏色
cell2.BackColor = System.Drawing.Color.Red; //設定文字顏色
row.Cells.Add(cell2);
TableCell cell3 = new TableCell();
cell3.Text = "表格第三列";
row.Cells.Add(cell3);
//產生表格
Table1.Rows.Add(row);
}
}
範例下載
很棒的做法...我都沒有想出來...這個動態製作table真讚
回覆刪除大大首先感謝您的分享~我用了變成這樣耶:
回覆刪除剖析器錯誤
描述: 當剖析服務此要求所需的資源時發生錯誤。請檢閱下列的特定剖析錯誤詳細資訊,並且適當地修改您的原始程式檔。
剖析器錯誤訊息: 型別 'System.Web.UI.WebControls.Button' 沒有名為 'table' 的公用屬性。
原始程式錯誤:
行 23:
行 24:
行 25:
行 26:
行 27:
原始程式檔: /f001.aspx 行: 25
請問可能是哪裡的問題??
是不是少輸入 run at server 呢
刪除