query.OutFields.AddRange(new string[] { "STATE_NAME", "STATE_ABBR" });
//or simply use * to return all fields -- query.OutFields.Add("*");
Oh I see what the problem is now. In this sample http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AttributeQuery (if you are using this), the query OutFields only include "STATE_NAME".
The service that it's using is http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5 and "STATE_ABBR", while it is a valid field, is not included in the OutFields. You can update this line
query.OutFields.AddRange(new string[] { "STATE_NAME", "STATE_ABBR" }); //or simply use * to return all fields -- query.OutFields.Add("*");
if ((args.UserState as string) == "initial") { // Just show on initial load QueryComboBox.Items.Add("Select..."); foreach (Graphic graphic in args.FeatureSet.Features) { QueryComboBox.Items.Add(graphic.Attributes["STATE_ABBR"].ToString()); } QueryComboBox.SelectedIndex = 0; return; }
query.Where = string.Format("STATE_ABBR = '{0}'", QueryComboBox.SelectedItem);
int min = 32, max = 33; query.Where = string.Format("STATE_ABBR = '{0}' and MED_AGE < {1}and MED_AGE_M > {2}", QueryComboBox.SelectedItem, min, max);
TypeDescComboBox.ItemsSource = (from g in args.FeatureSet.Features select g.Attributes["TYPEDESC"]).Distinct();