I want to print a table dynamically based on an array I have, using the RadGrid. The problem is that I am new to telerik and to ASP.NET.
What I would do in PHP is:
<?php
$data = stuff;
?>
<table>
<?php foreach($data as $dataOne): ?>
<tr><td><?php echo $dataOne; ?></td></tr>
<?php endforeach; ?>
</table>
Now I want to do the same in ASP.NET using RadGrid.
Thanks.
EDIT:
The data is returned as an XML with “Objects”, each has several fields, including names and numbers. I want the table to show all of it. I can parse the XML to several arrays (each array holds one column), or to objects, or to anything else. I need to know how to then put it in to the RadGrid.
Equivalent code in ASP.NET:
And you’ll have your gridview defined as so on the aspx page:
UPDATE:
I will give you an example using custom business Objects since you say you can parse the XML and create objects.
Having a class structure like below:
And assuming you parse the XML to construct an
Employee[]that you want to display on your grid in a manner similar to this:Your markup should look like this:
You add a handler to ItemDataBound event and implement it as so (pay attention to the markup above, which defines this handler):
Now, a full sample implementation that would render the grid as displayed on my example above is the below:
Note: None of the code has been tested, cut me some slack if it doesn’t work straight away. It is definitely close to this.