Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7821089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:32:02+00:00 2026-06-02T07:32:02+00:00

I want to print a table dynamically based on an array I have, using

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:32:03+00:00Added an answer on June 2, 2026 at 7:32 am

    Equivalent code in ASP.NET:

    var data = getDataFromDB(); 
    
    telerikGrid.DataSource=data;
    telerikGrid.DataBind();
    

    And you’ll have your gridview defined as so on the aspx page:

    <telerik:radgridview id="telerikGrid" runat="server" />
    

    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:

    public class Employee
    {
        public string EmployeeName {get;set;}
        //... And more properties
        Public Child[] Children {get;set;}
    }
    
    public class Child
    {
       public string Name {get;set;}
       //and more properties
    }
    

    And assuming you parse the XML to construct an Employee[] that you want to display on your grid in a manner similar to this:

    -------------------------------
    | Employee Name  |   Children |
    +-----------------------------+
    |  John          |   Peter    |
    |                |   Charles  |
    +----------------+------------+
    | Michael        |   Anna     |
    +-----------------------------+
    

    Your markup should look like this:

    <telerik:radgridview id="telerikGrid" runat="server" OnItemDataBound="telerikGrid_ItemDataBound">
     <MasterTableView AutoGenerateColumns="false">
          <Columns>
           <telerik:GridBoundColumn DataField="EmployeeName" HeaderText="EmployeeName">
           </telerik:GridBoundColumn>
           <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <telerik:radgridview runat="server" id="gridEmpChildren">
                       <MasterTableView AutoGenerateColumns="false">
                          <Columns>
                              <telerik:GridBoundColumn DataField="Name"                                       HeaderText="Children">
           </telerik:GridBoundColumn>
                          </Columns>
                       </MasterTableView>
                    </telerik:radgridview>
                </ItemTemplate>
           <telerik:GridTemplateColumn>
     </MasterTableView>
    </telerik:radgridview>
    

    You add a handler to ItemDataBound event and implement it as so (pay attention to the markup above, which defines this handler):

    protected void telerikGrid_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            RadGridView childrenGrid = (RadGridView)item.FindControl("gridEmpChildren"); 
            childrenGrid.DataSource= item["Children"];//See class Employee
            childrenGrid.DataBind();
        } 
     } 
    

    Now, a full sample implementation that would render the grid as displayed on my example above is the below:

     //Sample data
     Employee[] employees = new Employee[] {
        new Employee{
                EmployeeName="John",
                Children= new Child[]{
                        new Child{Name="Peter"},
                        new Child{Name="Charles"}
                        }
            }
            ,new Employee{
                EmployeeName="Michael",
                Children=new Child[]{
                        new Child{Name="Anna"}
                        } 
            }
    };
    
    telerikGrid.DataSource=employees;
    telerik.DataBind(); 
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this multi dimentional array that i want to print into a table
I have a program in C that print a table. I want update the
I print out a bunch of DDL statements that are dynamically created and want
I have a gridview that i want to print its header on every page
I want to print the contents of a div(a table containing info) using jquery.
In jsp I'm using Display tag to print a table. I want to display
I want to print some objects in a table having 2 rows per object,
I'm currently trying dynamically create an html table in PHP. Further, I want the
I have DB table defined with four columns: short, controller, action, id And using
I want to dynamically load images from a database withing a PrimeFaces data table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.