.net - Adding column in a datatable with a dynamic column name in C# -


datatable dt = new datatable(); var dr = dt1.date;  string rr = convert.tostring(dr);  datacolumn dc1=new datacolumn();  dc1.columnname = rr; dt.columns.add(dc1); 

and if add datarow after like

dt.rows.add("hello","hello1","hello2");   datagrid1.itemssource = dt.defaultview; 

the data not displayed in grid . if comment line

dc1.columnname = rr; 

the values displayed want colmn name date "dt1" here

pleae note dt1 date values dynamic , incremented in each loop.

dt1 = dt1.adddays(1); 

please help

without seeing xaml data grid it's difficult sure imagine you've specified field name date column in xaml.

to resolve this, you'll need set autogeneratecolumns=true , let grid automatically find field name.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -