MVVM - Add one Column Dynamically in RadGridView

2 posts, 0 answers
  1. Padmaja
    Padmaja avatar
    1 posts
    Member since:
    Sep 2014

    Posted 26 Jan 2015 Link to this post


    My application is in MVVM. I have a RadGridview where 2 columns are Databound and I have to generate third column dynamically with RowNumbers.
    Here is my code. I am getting (collection) in the third column. The other 2 columns are fine. Please help me on this. 


    <telerik:RadGridView  Name="TestGridView"  ItemsSource="{Binding TestListView}" AutoGenerateColumns="False">
                                <telerik:GridViewColumn Header="RowCount">
                                                <TextBlock Text="{Binding TestRowNumber}"  />
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="NetBIOS Name" />
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Salary}" Header="Model" />


    public void Testupdate()
                RadObservableCollection<int> rno = new RadObservableCollection<int>();
                for (int i = 1; i <= TestList.Count; i++)
              TestRowNumber= rno;

      private RadObservableCollection<int> _testRowNumber;
            public RadObservableCollection<int> TestRowNumber
                get { return _testRowNumber; }
                    _testRowNumber = value;

    Its showing correct count in the rno with items 1 to 6. But when displaying on the grid, its showing (collection). I am not able to trace where I am going wrong. Please correct me.

    Thank you.

  2. Boris
    Boris avatar
    276 posts

    Posted 29 Jan 2015 Link to this post

    Hi Padmaja,

    In your case you are getting a collection in your third column because its bound to a collection on the business object level. A possible way to go about this is define the property from your business object as a simple integer. In addition you can check our RowNumber WPF / Silverlight demo which demonstrates how you can make such a column.

    I hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top