Hi Yamunadevi,Thank you very much! I am able to generate different datagrid based on your suggestions! 🙂 That is so much powerful!! Here is my codes. But for some reasons I cannot get the correct query results. I specify the attribute fields that I want, but it doesn't show, instead, it shows the information like the picture in the attachment. Any suggestions for this problem?
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
//bind data grid to query results
Binding resultFeaturesBinding = new Binding("LastResult.Features");
resultFeaturesBinding.Source = queryTask;
// Specify fields to return from query according to different layers
if (selectlayerid == 9)
{
DataGrid dg = rectangleselection.QueryDetailsDataGrid;
List <string> Colnames = new List <string> {"OBJECTID", "NAME", "AREA_SQMI", "POP_1990", "POP_2000", "FIPS_CNTY"} ; //header name of the column
dg.Columns.Clear();
if (dg != null)
{
if (Colnames != null && Colnames.Count > 0)
foreach (string col in Colnames)
{
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
Binding binder = new Binding();
//you can use the converter if you are binding IDictionary to the datagrid
//binder.Converter = new AttributeRowIndexConverter();
// binder.ConverterParameter = col;
binder.Path = new PropertyPath("Attributes");
dataGridTextColumn.Header = col;
binder.Mode = BindingMode.OneWay;
dataGridTextColumn.Binding = binder;
dg.Columns.Add(dataGridTextColumn);
}
}
rectangleselection.QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
query.OutFields.AddRange(new string[] { "OBJECTID", "NAME_CNTY", "AREA_SQMI", "POP_1990", "POP_2000", "FIPS_CNTY" });
}
[ATTACH]6259[/ATTACH]