|
查看: 1049|回复: 2
|
ASP.NET - 怎样用looping来从table读取values
[复制链接]
|
|
|
怎样用looping(for loop)来从html table读取values(textbox, dropdownlist, etc etc)呢?
我用的方式如下。。。
在aspx弄一个"空"table
<asp:Table ID="tblSectionC" runat="server"></asp:Table>
在 code里,是用add row/add cell的方式来dynamicaly create那个table
Dim tRow As TableRow
Dim tCellQues As TableCell
Dim tCellInstr As TableCell
tRow = New TableRow
tCellQues = New TableCell
.
.
.
.
tRow.Cells.Add(tCellQues)
.
.
.
tRow.Cells.Add(tCellInstr)
.
.
tblSectionC.Rows.Add(tRow)
然后,当我读取那些table里的value
For Each dgItem In tblSectionC.Rows
.
.
.
.
.
Next
请问下,在哪里有出错呢?
我的问题出在,当到了for each dgitem in tblsectionC.rows的时候,就好像rowcount=0那样,直接跳到next。
当我trace code的时候,的确tblsectionC的row count = 0。但是runtime的时候,那个table的确已经是有了5个row了,但是却显示0。 |
|
|
|
|
|
|
|
|
|
|
发表于 28-6-2009 11:32 AM
|
显示全部楼层
For Length = 0 To tblSectionC.row.count -1
value = tblSectionC.row(Length).item(0)
Next
 |
|
|
|
|
|
|
|
|
|
|
发表于 7-7-2009 06:21 PM
|
显示全部楼层
是不是当你按delete button时,system 跑去page_load那里,所以伱的table变空了呢?
如果是,你要在page_load写
if not page.ispostback
你的code
end if |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|