哪位大虾能帮我研究一下下面这段代码错在哪里了,谢谢了
<script language ="vb" runat = "server">Sub Page_Load(sender As Object,e As EventArgs )
If not Page.IsPostBack then
MySelect1.Items.Add("1")
MySelect1.Items.Add("2")
MySelect1.Items.Add("3")
MySelect1.Items.Add("4")
MySelect2.Items.Add("1")
MySelect2.Items.Add("2")
MySelect2.Items.Add("3")
MySelect2.Items.Add("4")
End If
End Sub
Sub btnTable_Click(sender As Object,e As EventArgs)
Dim i,j,NumOfRow,NmOfCell As Integer
Dim MyTableRow,MyTableCell As Object
NumOfRow =(MySelect1.Value)
NmOfCell =(MySelect2.Value)
for j=1 to NumOfRow
MyTableRow =new HtmlTableRow()
for i=1 to NmOfCell
MyTableCell=new HtmlTableCell()
MyTableCell.InnerHtml=("第"+j+"行,第"+i+"列")
MyTableRow.Cells.Add(MyTableCell)
Next
MyHtmlTable1.Rows.Add(MyTableRow)
Next
End Sub
</script>
<html>
<head>
<title>HTML中Table控件的使用</title>
</head>
<body id ="body1" runat ="server">
<form id="form1" runat =server>
<table id ="MyHtmlTable1" runat ="server" CellPadding="4" CellSpacing ="1" Border="1" BorderColor="Blue"/><P>
</table>
<b>行数:</b>
<select id ="MySelect1" runat = "server"/><br>
<b>列数:</b>
<select id ="MySelect2" runat = "server"/>
<input type ="submit" value ="生成新表格" OnServerClick="btnTable_Click" runat ="server">
</form>
</body>
</html>
程序代码:
<SCRIPT language=vb runat="server"> Sub Page_Load(sender As Object,e As EventArgs ) If not Page.IsPostBack then MySelect1.Items.Add("1") MySelect1.Items.Add("2") MySelect1.Items.Add("3") MySelect1.Items.Add("4") MySelect2.Items.Add("1") MySelect2.Items.Add("2") MySelect2.Items.Add("3") MySelect2.Items.Add("4") End If End Sub Sub btnTable_Click(sender As Object,e As EventArgs) Dim i,j,NumOfRow,NmOfCell As Integer Dim MyTableRow,MyTableCell As Object NumOfRow =(MySelect1.Value) NmOfCell =(MySelect2.Value) for j=1 to NumOfRow MyTableRow =new HtmlTableRow() for i=1 to NmOfCell MyTableCell=new HtmlTableCell() MyTableCell.InnerHtml=("第"+j+"行,第"+i+"列") MyTableRow.Cells.Add(MyTableCell) Next MyHtmlTable1.Rows.Add(MyTableRow) Next End Sub </script>