下面是我写的例题,因为是新手,所以问的问题有点差劲。asp.net,C#
1、红色加粗的代码是需要自己手写上去的吗?
2、这段代码里,蓝色部分原始值为false,可是在这段代码的功能中,必须改成true,才能实现。
请帮我解释一下好吗。
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true" Inherits="WebApplication8.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="C#" runat="server">
void Page_Load(Object sender,EventArgs e)
{
int numrows = int.Parse(DropDown1.SelectedItem.Value);
int numcells = int.Parse(DropDown2.SelectedItem.Value);
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("行" + j.ToString() + "单元格" + i.ToString()));
r.Cells.Add(c);
}
Table1.Rows.Add(r);
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P><FONT face="宋体">动态生成表</FONT></P>
<P><FONT face="宋体">
<asp:Table id="Table1" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
CellPadding="5" CellSpacing="0" GridLines="Both"></asp:Table></FONT></P>
<P><FONT face="宋体">表行:
<asp:DropDownList id="DropDown1" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>表单元格:
<asp:DropDownList id="DropDown2" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList></FONT></P>
<P>
<asp:Button id="Button1" runat="server" Text="生成表"></asp:Button></P>
</form>
</body>
</HTML>
[此贴子已经被作者于2007-10-20 10:35:06编辑过]