Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Surely you simply need to repopulate the second combo box's items when the user makes a selection in the first?</p> <p>You likely don't want to requery the database each time the user makes a selection and so instead will want to hold a structure in memory of all valid facets keyed on toolid.</p> <p><strong>EDIT</strong> some further detail based on Dave's comment:</p> <p>Assuming that you already have some code setup to query the database, you want to execute a query (or queries) that give you back the relevant data to hold in a cache and do this as part of your app's initialisation after connecting to the database. You could create two dictionaries to hold the tool and facet data. For example:</p> <pre><code>Dictionary&lt;int, string&gt; _tools = new Dictionary&lt;int, string&gt;(); Dictionary&lt;int, string&gt; _facets = new Dictionary&lt;int, string&gt;(); </code></pre> <p>and then a third structure that basically holds the data in tool_facet:</p> <pre><code>Dictionary&lt;int, List&lt;int&gt;&gt; _tool_facets = new Dictionary&lt;int, List&lt;int&gt;&gt;(); </code></pre> <p>these basically give you an in-memory copy of the tables that you can very quickly enumerate to populate combo boxes. You'll want to populate the combo boxes with something that holds the ID and a description, something like this will do:</p> <pre><code>class ComboBoxIntItem { private readonly int _id; private readonly string _name; public ComboBoxIntItem(int id, string name) { _id = id; _name = name; } public override string ToString() { return _name; } public int GetId() { return _id; } } </code></pre> <p>I'm assuming here that you need to know the tool and facet IDs that the user has selected. If you only care about the names then you could just use a single structure like this:</p> <pre><code>Dictionary&lt;string, List&lt;string&gt;&gt; _tool_facets = new Dictionary&lt;string, List&lt;string&gt;&gt;(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload