This is a migrated thread and some comments may be shown as answers.

Data Bind List of ExpandoObject

1 Answer 257 Views
Grid
This is a migrated thread and some comments may be shown as answers.
temperory temperory
Top achievements
Rank 1
temperory temperory asked on 23 Oct 2012, 02:40 PM
Hi 

How I can override RadGrid to Data bind a list of ExpandoObjects.

Sample Code :

List<ExpandoObject> viewList = new List<ExpandoObject>();
for (int i = 0; i < 100; i++)
{
    dynamic view = new ExpandoObject();
    var p = view as IDictionary<String, object>;
    p["LatName"] = i * 2;
    p["Name"] = i;
    viewList.Add(view);
}
RadGrid1.DataSource = viewList;
RadGrid1.DataBind();
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" CellSpacing="0"
    GridLines="None">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter column column"
                  HeaderText="Name" UniqueName="column">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 26 Oct 2012, 06:17 AM
Hello,

You can finda solution at the following forum discussion.

http://www.telerik.com/community/forums/aspnet-ajax/grid/using-dynamicobject-as-a-datasource-or-expandoobject.aspx


Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
temperory temperory
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or