Select to view content in your preferred language

Problem with Binding datagrid  into code behind

681
3
02-12-2014 06:53 AM
Abdoulaye_Djibril_MademouDIALL
Emerging Contributor
Hi everyone,
i have a problem with binding datagrid into code behind

indeed i have the code below

               dataGrid1.Columns.Clear();
                for (int i = 0; i < mylistChamp.Count; i++)  //mylistChamp is a  liste of the fields in the featurelayer
                {
                   
                    DataGridTextColumn dgc = new DataGridTextColumn();
                    String c = mylistChamp;                 
                    dgc.CanUserSort = true;
                    dgc.SortMemberPath = mylistChamp;
                    dgc.Binding = new System.Windows.Data.Binding("Attributes");            // The line with the problem
                    dgc.Header = mylistChamp;
                    dataGrid1.Columns.Add(dgc);
                   
                }

the code below can not work but if i replace the line: dgc.Binding = new System.Windows.Data.Binding("Attributes")
with dgc.Binding = new System.Windows.Data.Binding("Attributes[NAME]") where NAME represent the Fields the code work well

Please Someone Can Help me ?
0 Kudos
3 Replies
SheridanNava
Occasional Contributor
Have you try just binding the name of the field?  System.Windows.Data.Binding("field") or System.Windows.Data.Binding(c) in your case?
0 Kudos
Abdoulaye_Djibril_MademouDIALL
Emerging Contributor
thanks Snava for the reply ,
in fact i try binding System.Windows.Data.Binding(c) but c represent the fields because somewhere in the code i write
c=mylistChamp;// mylistChamp represent the liste of all the fields in my featurelayer
is it clear ??
0 Kudos
Abdoulaye_Djibril_MademouDIALL
Emerging Contributor
it's good I found
i write dgc.Binding = new System.Windows.Data.Binding("Attributes[" + c + "]") instead of i  dgc.Binding = new System.Windows.Data.Binding("Attributes["") .
Thanks for the help
0 Kudos