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

Binding Radgrid columns with child object list

1 Answer 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adonis
Top achievements
Rank 1
Adonis asked on 30 Sep 2013, 04:16 PM
Hello,

I have a Radgrid where I an creating the columns dynamically on page_load, when databound the data shouws fine except where I created columns bound to a child object which in this case is a list of integers, those columns are created as shown below

for (i = 0; i < weeks; i++)
                   {
                       AddGridColumns(Grid, "ChildList[" + i.ToString() + "]", "HeaderText");
                        
 
                   }

private void AddGridColumns(RadGrid Grid, string DataField,string HeaderText)
        {
              
            GridBoundColumn boundColumn = new GridBoundColumn();
            Grid.MasterTableView.Columns.Add(boundColumn);
            boundColumn.DataField = DataField;
            boundColumn.HeaderText = HeaderText;
            boundColumn.UniqueName = DataField;
   
        }


I have confirmed that the list contains data at the respective indexes and the rest of the columns show data as expected, any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Oct 2013, 08:31 AM
Hi Adonis,

Please try setting the DataFormatString,of the radgrid rather than the DataField.

C#:
private void AddGridColumns(RadGrid Grid, string value, string HeaderText)
   {
       GridBoundColumn boundColumn = new GridBoundColumn();
       Grid.MasterTableView.Columns.Add(boundColumn);
       boundColumn.DataFormatString = value;      
       boundColumn.HeaderText = HeaderText;
       boundColumn.UniqueName = value;
   }

Thanks,
Princy
Tags
Grid
Asked by
Adonis
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or