佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1049|回复: 2

ASP.NET - 怎样用looping来从table读取values

[复制链接]
发表于 16-6-2009 02:41 PM | 显示全部楼层 |阅读模式
怎样用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。
回复

使用道具 举报


ADVERTISEMENT

发表于 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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 8-12-2025 04:04 PM , Processed in 0.118192 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表