[ASP.NET][Control] Table 操作範例

摘要:[ASP.NET]控制項 Table 操作範例

 

.aspx

<asp:Table ID="Table1" runat="server">
</asp:Table>

 

.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {  
        SPEC2008DSWControlClass scc = new SPEC2008DSWControlClass();
        if (Request.QueryString["PURPOSE"].ToString().Contains("PROMO"))
        {
            OracleDataReader odrSP02_PK = scc.PromoOrderNums(Request.QueryString["OrderNum"].ToString());
            if (!odrSP02_PK.HasRows)
            {
                Message m = new Message(@"錯誤SLT: 查不到BOM PK 和 SR# !!!", Page);
            }

            else
            {
                OracleDataTable odt = new OracleDataTable();
                odt.Load(odrSP02_PK);
                if (odt.Rows.Count > 1)
                {
                    for (int i = 0; i < odt.Rows.Count;i++)
                    {
                        Table1.Rows.Add(CreateTableRow(odt.Rows[i][0].ToString()));
                    }

                 }

            }

        }
  
    }


    TableCell CreateTableCell(string tcTxt,Boolean bl)
    {
        TableCell tc = new TableCell();
        if (bl)
        {
            tc.Text = tcTxt;
            tc.Font.Name = "C39HrP24DhTt";
            tc.Font.Size = 48;
        }

        else
        {
            SPEC2008DSWControlClass scc = new SPEC2008DSWControlClass();
            tc.Text = scc.PPM(tcTxt);
            tc.Font.Size = 14;
        }

        return tc;
    }


    TableRow CreateTableRow(string tcTxt)
    {
        TableRow tr = new TableRow();
        tr.Cells.Add(CreateTableCell(tcTxt,true));
        tr.Cells.Add(CreateTableCell(tcTxt,false));
        return tr;
    }