我想在C#中创建一个动态表格,动态Adding and deleting of row
我需要two columns
,Column 1 as label
和column 2 as button
,我希望该表添加来自其他一些方法..
并单击第2列的按钮,我希望特定行只能删除.. 例如:
COL1 COL2
label button(to delete row)
(添加)
我正在尝试的是: 在aspx中
<asp:Table border="1" id="Table1" runat="server">
</asp:Table>
在C#中
for (int i = 0; i < 3; i++)
{
TableRow row = new TableRow();
for (int j = 0; j <2; j++)
{
TableCell cell = new TableCell();
// Add the control to the TableCell
LinkButton tb1 = new LinkButton();
if (IsOdd(j))
{
Label tb = new Label();
tb.Width = 100;
// Set a unique ID for each zTextBox added
tb.ID = "TextBoxRow_" + i + "Col_" + j;
tb.Text = "asdad";
cell.Controls.Add(tb);
}
else
{
tb1.Width = 100;
// Set a unique ID for each zTextBox added
tb1.ID = "TextBoxRow_" + i + "Col_" + j;
tb1.Text = "asdad";
cell.Controls.Add(tb1);
}
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
Table1.Rows.Add(row);
}