Dynamically generate ASP.NET control lanxin - Reprinted (2004-8-17 10:26:00) Category: .NET Controls Develop Your Points: 28 Dynamic Generate ASP.NET Controls as follows: Public Void CreateDataGrid () {DataTable FlowTable = new WorkFlowBLL () GetFlowTableByCode (FunctionCode);. foreach (DataRow dataRow in flowTable.Rows) {Table table = new Table (); table.CellPadding = 0; table.CellSpacing = 0; table.Width = Unit.Percentage (98 Table.attributes.add ("align", "center"); table.attributes.add ("style", "Height: expness (Document.Body.OffsetHeight-Toolbar.OffsetHeight-SpaceBar.offsetHeight-33)") Table.cssClass = "PLPANelunselect"; table.attributes.add ("imagessrc", "images / contact.gif"); table.attributes.add ("panelcaption", (String) DataRow ["BMC"]); tableerow TableRow = new tableRow (); Tablecell Tablecell = new TableCell (); Tablecell.VerticalAlign = VerticalAlign.top; Panel Panel = new panel (); panel.attributes.add ("style", "Overflow: auto; width: 100% Height: 100% "); DataGrid = New DataGrid (); DataGrid.BorderWidth = 0; DataGrid.id = (String) DataRow [" BDM "]; DataGrid.enableViewState = False; dataGrid.wid th = Unit.Percentage (100); dataGrid.Font.Size = FontUnit.Parse ( "12px"); dataGrid.Style [ "border-collapse"] = "none"; dataGrid.ItemDataBound = new DataGridItemEventHandler (dataGrid_ItemDataBound); . dataGrid.DataSource = new WorkFlowBLL () GetFlowDataByCode (FunctionCode, (string) dataRow [ "BDM"], DataCode); dataGrid.DataBind (); panel.Controls.Add (dataGrid); tableCell.Controls.Add (panel); Tablelow.cells.add (Tablecell); Table.Rows.Add (TableRow); PlaceHolder.controls.Add (Table);