2017-03-23 6 views
0

내가 동적으로동적으로 asp.net VB

Dim tRow As New TableRow() tblKategorie.Rows.Add(tRow)Dim tCell As New TableCell() tRow.Cells.Add(tCell)

하지만 지금은 이런 복잡한 테이블을 필요로 일반 테이블을 만들 수 있습니다 테이블을 만듭니다 동적으로? 이 결과를 얻기 위해 셀과 열을 병합하려면 어떻게해야합니까? 이 내용을 이해하는 데 도움이 될 예제 또는 링크에 대해 매우 감사 할 것입니다.

+0

http://stackoverflow.com/questions/39585562/setting-rowspan-for-dynamic-rows-in-asp-net-table-control https://msdn.microsoft.com/en -us/library/system.web.ui.webcontrols.tablecell.rowspan (v = vs.110) .aspx https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols .tablecell.columnspan (v = vs.110) .aspx –

답변

2

RowSpanColumnSpan을 사용합니다.

'create a new table with some properties 
Dim table As Table = New Table 
table.CellPadding = 5 
table.CellSpacing = 0 
table.Width = 500 
table.Height = 200 

'this is just to visualize the layout 
table.Attributes.Add("border", "1") 

'the first row that spans all 3 columns 
Dim row1 As TableRow = New TableRow 
Dim cell1a As TableCell = New TableCell 
cell1a.ColumnSpan = 3 
row1.Cells.Add(cell1a) 

'the second row where the first column spans 3 rows 
Dim row2 As TableRow = New TableRow 
Dim cell2a As TableCell = New TableCell 
cell2a.RowSpan = 3 
Dim cell2b As TableCell = New TableCell 
Dim cell2c As TableCell = New TableCell 
row2.Cells.Add(cell2a) 
row2.Cells.Add(cell2b) 
row2.Cells.Add(cell2c) 

'the third row where the second column spans 2 rows 
Dim row3 As TableRow = New TableRow 
Dim cell3b As TableCell = New TableCell 
cell3b.RowSpan = 2 
Dim cell3c As TableCell = New TableCell 
row3.Cells.Add(cell3b) 
row3.Cells.Add(cell3c) 

'the last row containing just one cell 
Dim row4 As TableRow = New TableRow 
Dim cell4c As TableCell = New TableCell 
row4.Cells.Add(cell4c) 

'add the rows to the table 
table.Rows.Add(row1) 
table.Rows.Add(row2) 
table.Rows.Add(row3) 
table.Rows.Add(row4) 

'add the table to the placeholder 
PlaceHolder1.Controls.Add(table) 
+0

정말 고마워요. 이것은 나를 많이 도왔고 앞으로 도움이 될 것입니다. –