Click here to Skip to main content
14,935,565 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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>

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>

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
Posted
Updated 30-May-11 6:39am
v4
Comments
Sergey Alexandrovich Kryukov 30-May-11 12:37pm
   
What's the question?
--SA
tihcra 30-May-11 12:39pm
   
i want to know what should i write for aspx page and what should code should be written in codebehind c# file
   
OK, I think you got a good solution. Will you formally accept it?
--SA
tihcra 30-May-11 13:04pm
   
basically where to add javascript code and how to call it ?

1 solution

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
   
Comments
   
Looks like a handy tutorial; you usually suggest useful reading; my 5.
--SA
   
I advised OP to accept it formally as the solution.
--SA
Espen Harlinn 7-Jun-11 10:57am
   
Thank you, SAKryukov!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900