table控制元件的基本用法

wangjun_pfc發表於2007-10-04
protected void Button1_Click(object sender, EventArgs e)
    
{
        
int row = int.Parse(DropDownList1.SelectedValue);
        
int cell = int.Parse(DropDownList2.SelectedValue);

        
for (int i = 1; i <= row; i++)
        
{
            TableRow tr 
= new TableRow();
            
for (int j = 1; j <= cell; j++)
            
{
                TableCell tc 
= new TableCell();
                Label lbl
=new Label();
                lbl.Text
=i+"  "+j+",";

                tc.Controls.Add(lbl);
                tr.Controls.Add(tc);
            }

            Table1.Controls.Add(tr);
        }

    }
 

相關文章