我的问题是:我有一个精简的default.aspx
页面。除了一个元素,几乎所有的功能都必须在aspx.vb
.
该程序从数据库中检索信息并将其与另一个表列表进行比较,两个列表的数量可能会有所不同。
所以我需要将动态数量的 RadioButtonLists “绑定”到asp:table
元素控件,并且我需要为创建的每个 RadioButtonList 创建动态数量的 ListItems。稍后,我需要能够访问每个选定的值,以便决定数据库中的未来功能。
代码示例如下:
.aspx 文件:
<asp:table ID="table1" runat="server">
aspx.vb 文件(代码隐藏):
Sub createHtmlTables()
For i = 0 To productIndex.Count - 1
''//create a RadioButtonList for each i
Dim row As New TableRow
Dim cell As New TableCell
For k = 0 To productTypeAmountIndex.Count - 1
''//create a ListItem(radiobutton)
''//for each k and include it in the RadioButtonList
''//assign a value (for example name) of the product as
''//the ListItems ID to retreive it later
Next
''//add the RadioButtonList to cell.controls etc
Table1.Rows.Add(row)
Next
End Sub
Sub addToDb()
For i = 0 To productIndex.Count - 1
''//get the RadioButtonList for each i
''//and return the value of the selected radiobutton
''//within the list to a variable
Next
End Sub
抱歉,如果这很长而且令人困惑,但由于我什至还不能正确地提出我的问题,所以我试图包含尽可能多的信息。基本上我只需要一个例子来说明如何以及使用哪些方法来使所有这些工作。
更新:
每个人都一直告诉我,从表格开始是一个错误,但是我发现的某个地方声称您不能像使用表格那样轻松地自定义数据网格的外观。我想我会从头开始整件事。
问题是 UI 应该尽可能图形化,使用表格我可以做各种整洁的事情,例如根据里面的信息为单元格着色等。
无论如何,谢谢,但不是我想要的,但我会尝试用 datagrid / gridview 重新制作这个东西,看看会发生什么。可能需要几天的时间,我才能学到足够多的东西来使用它们并回到这里。