We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Reg: Copy data from GridGroupingControl to DataTable

Hi, Source for GridGroupingConrol - DataTable DataTable dt; dt = dataTable.Copy(); If i do copy like this, what is there in dataTable is directly come to my dt(datatable).But i need grid look and feel to dt. Problem Example: If datatable column contain name for example Asset_ID,but while showing in to grid they are showing like this ''Asset'' Q1: I need datatable like what is there in grid.? Help me..!

5 Replies

AD Administrator Syncfusion Team July 4, 2005 01:14 PM UTC

Here is a sample that will move the columns into a datatable in the sample order as the grid if that is what you mean by look and feel. http://www.syncfusion.com/Support/user/uploads/ggc_DT_b3e8e41f.zip


AS Anna Srinivasan July 5, 2005 04:44 AM UTC

Hi, Example is working fine....! All records which are present in the grid i can able to get in the dataTable except column headers. Colummn headers i am getting what is there in grid control source dataTable. How do i get column header what is there in gridgrouping control..? Thanks, Anna


AD Administrator Syncfusion Team July 5, 2005 08:40 AM UTC

Instead of naming the columns using cd.Name, name them with the HeaderText. foreach(GridVisibleColumnDescriptor cd in this.gridGroupingControl1.TableDescriptor.VisibleColumns) { string s = this.gridGroupingControl1.TableDescriptor.Columns[cd.Name].HeaderText; dt.Columns.Add(new DataColumn(s, this.gridGroupingControl1.TableDescriptor.Columns[cd.Name].FieldDescriptor.GetPropertyType())); }


AS Anna Srinivasan July 5, 2005 11:19 AM UTC

Hi, In your example , i need to change any of the code in this line. dr[cd.Name] = r.GetValue(cd.Name); b''cause. If i dint change i am getting following error. Additional information: Column ''OUTST_QTY'' does not belong to table . Note : ''OUTST_QTY'' this column belongs to grid source table One more thing , I tried with header text string in [dr[cd.Name] = r.GetValue(cd.Name);] this point i am getting only header but not data which are present in the grid. Help me...!


AD Administrator Syncfusion Team July 5, 2005 12:34 PM UTC

Here is a sample that has different headertext than column names. http://www.syncfusion.com/Support/user/uploads/ggc_DT_679e7885.zip

Loader.
Live Chat Icon For mobile
Up arrow icon