通过asp.net动态生成网页 [英] dynamically generate a webpage via asp.net

查看:55
本文介绍了通过asp.net动态生成网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计一个表,该表的行是通过xml从另一个aspx页检索的. 说我有一个页面getstudents.aspx
它以以下格式为数据库中的所有学生提供了
------------

i want to design a table whose rows are retrieved from another aspx page via xml
say i have a page getstudents.aspx
which gives all the students in the database in the following format
------------

<allstudents>
	<student>
		<rollno>8001</rollno>
		<name>AAAA</name>
	</student>
	<student>
		<rollno>8002</rollno>
		<name>BBBB</name>
	</student>
</allstudents>


这样我就可以从getstudents.aspx中获取数据
现在我想设计一个页面selectstudents.aspx
输出以下html(每行带有一个复选框的表)
通过以下方式


this way i get data from getstudents.aspx
now i want to design a page selectstudents.aspx
which outputs following html (a table with a checkbox in each row)
in the following way

<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>
	</tr></table>
	<form id="form1" name="form1"> 
		
	</form>
</body>


带复选框的表在运行时动态生成
在下一个对应的列中具有复选框的ID,复选框的值(8001、8002等)和名称(AAAA,BBBB等)
通过读取页面getstudents.aspx给定的xml中的数据

勾选复选框时应调用一个函数(例如)addremove(this.id)
或取消选中该复选框,应在名为(例如)"values"的字符串数组中添加或删除复选框的值(8001,8002等)
然后,我将通过POST将包含"8001; 8002; 8003等"的字符串提交给网页
取决于选中了哪些复选框
显然,我将从数组值"中生成字符串
我不想在asp.net中使用现成的用户控件
我想做的事情比这要复杂得多,但这是它的简化版本.
所以为此,aspx页面的结构应该是什么,而在c#中应该是什么代码呢?

在此先感谢


the table with checkboxes is dynamically generated at runtime
with id of checkbox,value of checkbox(8001,8002,etc) and the name (AAAA,BBBB,etc) in the next corrosponding column
by reading data from xml given by page getstudents.aspx
also
a function (say) addremove(this.id) should be called whenever a checkbox is ticked
or unticked which should add or remove the value of checkbox (8001,8002,etc) to/from a string array named (say) ''values''
i will then submit to the webpage a string via POST containing "8001;8002;8003 and so on"
depending on which checkboxes are checked
obviously i will make the string from the array ''values''
i do not want to use readymade usercontrols avail in asp.net
what i want to do is more complicated than this, but this is a simplified version of it
so for this what should be structure of aspx page and what should be code behind in c#?

thanks in advance

推荐答案

您可能会找到 http://www .asp.net/data-access/tutorials [^ ]有趣.

之后,您将能够从getstudents.aspx中提取数据,创建一个DataTable,用数据填充它,并将其分配给DataGridView的DtaSource属性.

最好的问候
Espen Harlinn
You may find http://www.asp.net/data-access/tutorials[^] interesting.

Afterwards you will be able to pull data from getstudents.aspx, create a DataTable, fill it with the data, and assign it to tha DtaSource property of a DataGridView.

Best regards
Espen Harlinn


这篇关于通过asp.net动态生成网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆