I would like to query a layer, but also incorporate a find. Just like the "Find" and "Query attribute" examples but into one. Anyone have a simple one that's put together that you can share please?
How I can i modify the "Attribute Query" to instead of a drop down and select to just a search, input box. I would like to keep the "Attribute Query" functionality except make it into a search?
Replace the combobox with a textbox, add a "search" button and when clicked use the text in the textbox as the input, instead of the selected item in the combobox
Instead of using the dropdown list value as your query text use the text from a textbox then use a button click event to begin your search. Here is an example, using the syntax from the Attribute Query sample:
Dim query As New ESRI.ArcGIS.Client.Tasks.Query() query.OutFields.Add("*") query.Text = QueryComboBox.SelectedItem.ToString() (Change this to: TextBox.Text)
queryTask.ExecuteAsync(query)
You may also want to apply auto suggest to your text box to help users refine their searches.
Can you provide a copy of your "QueryButton_Click" code from the code-behind page? This is where you create your query task so I assume this is where your problems a coming from. Thanks,
I tried a different example and it seems to work ok except for the DataGridColumn displaying over the text box. Also when i try to search by State i get the following error "Query Failed.ESRI.ArcGIS.Client.Tasks.ServiceException??? Here is my current xaml.
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Tasks; using ESRI.ArcGIS.Client.Symbols; using ESRI.ArcGIS.Client.ValueConverters;
namespace SilverlightApplicationFindQuery { public partial class MainPage : UserControl { public MainPage() {InitializeComponent();}
In order for your state name query to work you will need to have the query syntax something like: query.Where = "STATE_NAME LIKE '%" +QueryTextBox.Text+ "%'"
As you can see from the example above the where statement needs to contain the field name and texbox syntax. I apologize if I did not make that clear in my last posting. I would recommend using just one field to search against unless you want to do some string interogation prior to creating the where string--you could check if the user is searching for numbers or strings and change the search field appropriately.
Your grid is being placed on-top of your search box because you have not configured your grid display margins correctly. You may want to place everything in a vertical stackpanel so that the grid is displayed below the textbox. In order to do this, you may want to add some logic to the display of the grid. For Example, only showing the grid if there are some features selected--try using a border around your grid and toggling the control to visible or not visible. There are other samples that use this method on the ESRI samples page.