动态表格

protected void BindTable(string Bargain_id)
    {
        string strTable;
        strTable = "  where Bargain_id = '" + Bargain_id + "'";
        DataSet dsTable = HouserBLL.GetDataListByStrWhere("GetT_BargainBindTable", strTable);
        int rowCount =int.Parse(dsTable.Tables[0].Rows.Count.ToString());
        int i = 0;
        System.Web.UI.WebControls.TableRow tr = new TableRow();
        while (i <=rowCount)
        {
            i = i + 1;
            System.Web.UI.WebControls.TableCell tc = new TableCell();
            tc.CssClass = "fontkuang";
            tc.ControlStyle.Width = 155;
            tc.ControlStyle.Height=30;
            tc.ControlStyle.BackColor = Color.White;
            tc.ControlStyle.BorderColor = Color.Wheat;
            tc.ControlStyle.BorderStyle = BorderStyle.Solid ;
            tc.BorderWidth = 1;
            tc.HorizontalAlign = HorizontalAlign.Center;
    
            for (int j= i; j<= rowCount;j++)
            {
                    tc.Text = dsTable.Tables[0].Rows[j-1]["OrderId"].ToString() + " " + dsTable.Tables[0].Rows[j-1]["TradeRecordName"].ToString();
                    break;
              
            }
            tr.Controls.Add(tc);
            if (i %6== 0)
            {
                this.Table1.Rows.Add(tr);
                tr = new TableRow();
            }
        }
        if (i % 6 != 0)
        {
            this.Table1.Rows.Add(tr);
        }
    }
posted @ 2008-05-18 22:17  熊忠荣  阅读(294)  评论(0编辑  收藏  举报