<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../Styles/basic.css" type="text/css">
<title>Table-3.aspx</title>
<script language="c#" runat="server">
void Button1_Click(Object sender,EventArgs e)
{
int numrows = int.FromString(DropDownList1.SelectedItem.Value);
int numcells = int.FromString(DropDownList2.SelectedItem.Value);
Tabel1.Style["Color"] = DropDownList3.SelectedItem.Value;
//Using Loop to Create Table
for(int j=0;j<numrows;j++)
{
     TableRow r = new TableRow();
     for(int i=0;i<numcells;i++)
     {
TableCell c = new TableCell();
  c.Controls.Add(new LiteralControl("Row:" + j.ToString()+", Cell:" + i.ToString()));
r.Cells.Add(c);
             }
Tabel1.Rows.Add(r);
}
}
</script>
</head>
<body>
<form runat="server">
     <asp:Table ID="Tabel1" BorderWidth="1px" GridLines="Both" Runat="server">
     </asp:Table>
     <p>
     Table Line:
<asp:DropDownList id="DropDownList1" runat="server" class="selectstyle">
<asp:ListItem Value="1">One Row</asp:ListItem>
<asp:ListItem Value="2">Second Rows</asp:ListItem>
<asp:ListItem Value="3">Three Rows</asp:ListItem>
<asp:ListItem Value="4">Four Rows</asp:ListItem>
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
         Table Cell:
<asp:DropDownList id="DropDownList2" runat="server" class="selectstyle">
<asp:ListItem Value="1">One Cell</asp:ListItem>
<asp:ListItem Value="2">Second Cells</asp:ListItem>
<asp:ListItem Value="3">Three Cells</asp:ListItem>
<asp:ListItem Value="4">Four Cells</asp:ListItem>
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tabel Color:
<asp:DropDownList id="DropDownList3" runat="server" class="selectstyle">
<asp:ListItem Value="red">Red Color</asp:ListItem>
<asp:ListItem Value="blue">Blue Color</asp:ListItem>
<asp:ListItem Value="green">Green Color</asp:ListItem>
<asp:ListItem Value="black">Black Color</asp:ListItem>
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<p>
<asp:Button 
id="Button1" 
Text="Create Tabel" 
OnClick="Button1_Click"
class="SubmitStyleSmall" 
Runat="server">
</asp:Button>
</form>
</body>
</html>