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

Manually insert rows with values in code behind

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 May 2011, 03:10 PM
Hi!

I'm trying to build a grid that will show x amount of columns depending on how much information is available for the current items.
Basically it's yearly information and I should show "Name, 2011, 2012, 2013..." etc.
so depending on the source which can be updated at runtime,
ExportGrid.Columns.Clear();
 
var column = new GridViewColumn();
column.Header = "Name";
ExportGrid.Columns.Add(column);
 
for (var i = 0; i < years; i++)
{
column = new GridViewColumn();
column.Header = (Year + i).ToString();
ExportGrid.Columns.Add(column);
}
UpdateExportGridInformation();

so depending on how the user filters another grid, I might have values for 2 years, starting at 1999 and I should therefore show 3 columns - Name, 1999, 2000. If the user changes the filter, the source might contain information for 4 years, starting 2002 - Name, 2002, 2003, 2004, 2005

I manage to create the columns like I'm showing in the code above. But I don't manage to add rows. How is it possible to do so?

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 24 May 2011, 10:01 AM
Hello John,

Rows comes from the ItemsSource of the grid which supplied the actual items that will be shown. I guess you case required creation of dynamic data to reflect the dynamic nature of your scenario.

You could try using our DataTable implementation which allows you to create rows and columns.

Hope this helps.


Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or