【发布时间】:2023-04-05 06:04:01
【问题描述】:
我想设计一个表,其行是通过 xml 从另一个 aspx 页面检索的。
假设我有一个页面getstudents.aspx,它以以下格式提供数据库中的所有学生:
<?xml version="1.0" encoding="utf-8"?>
<allstudents>
<student>
<rollno>8001</rollno>
<name>AAAA</name>
</student>
<student>
<rollno>8002</rollno>
<name>BBBB</name>
</student>
</allstudents>
这样我从getstudents.aspx 获取数据。
现在我想设计一个页面selectstudents.aspx
输出以下html(每行带有复选框的表格)
通过以下方式:
<head>
<script type="text/javascript">
var values[];
function add(x)
{
//adds the value of ticked checkbox in values array and removes it when unticked
}
</script>
</head>
<body>
<table>
<tr>
<td> </td>
<td>Name</td>
<tr>
<td><input type="checkbox" name="cbRoll" value="8001" id="cbRoll8001" /></td>
<td>AAAA</td>
</tr>
<tr>
<td><input type="checkbox" name="cbRoll" value="8002" id="cbRoll8002"/></td>
<td>BBBB</td>
</tr>
</table>
<form id="form1" name="form1">
</form>
</body>
带有复选框的表格是在运行时动态生成的 复选框的 id、复选框的值(8001、8002 等)和下一个对应列中的名称(AAAA、BBBB 等)。 通过从页面getstudents.aspx给出的xml读取数据 还 函数(例如)addRemove(this.id)应在勾选复选框时调用 或未选中应将复选框(8001,8002 等)的值添加到/从名为(例如)“值”的字符串数组中删除。 然后我将通过 POST 向网页提交一个包含“8001;8002;8003 等”的字符串 取决于选中的复选框 显然我会从数组“值”中创建字符串。
我不想使用在 asp.net 中可用的现成用户控件。 我想做的比这更复杂,但这是它的简化版本。
那么对于这个,aspx页面的结构应该是什么,C#中的代码应该是什么?
【问题讨论】:
标签: c# asp.net html-table