GridView DataSources Example (Dynamic Object Source)

2 posts, 0 answers
  1. Michael
    Michael avatar
    15 posts
    Member since:
    Dec 2009

    Posted 09 Mar 2012 Link to this post

    Hello,

    I've been having trouble getting this example to work in my own environment.  The Data Rows show up in the grid, however no columns are mapped. Below you will find the Xaml and code behind.  I copied and pasted the MyDataRow class from the example on the demo website... http://demos.telerik.com/silverlight/#GridView/DataSources

    Version of Telerik.Windows.Controls.GridView.dll is 2011.3.1220.1040.  Does this version of the Telerik controls support the dynamic binding? 

    XAML
    <Grid x:Name="layoutroot" Background="white">
        <telerik:RadGridView x:Name="RadGridView1"
                             RowIndicatorVisibility="Collapsed"                    
                              />
    </Grid>

    CodeBehind
        ObservableCollection<MyDataRow> data = new ObservableCollection<MyDataRow>();
     
        public GridViewTest()
        {
            InitializeComponent();
     
            RadGridView1.ItemsSource = data;
        }
     
        public void AddDataRow(Node root)
        {
            MyDataRow subscribers= new MyDataRow();
            clients["TimeStamp"] = DateTime.Now;
     
            foreach (var subscriber in root.Subscribers)
            {
                   subscribers[subscriber.ShortName] = subscriber.DoubleValue;
            }
     
            data.Add(clients);
        }      
    }

    Thanks,
    Michael
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Mar 2012 Link to this post

    Hi Michael,

    I have tested the code from the online demo. All the data was populated fine and I did not encounter any problems.
    From your second code snippet, I can see that you have an object "subscribers". Then you add an object "clients" to the data. How is the "clients" object defined?

    Regards,
    Didie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top