<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>CodeTrigger - General - Binding Foreign key fields to DropDown - Messages</title>
<link>https://www.codetrigger.com/forum/topic17-binding-foreign-key-fields-to-dropdown.aspx</link>
<description>CodeTrigger - General - Binding Foreign key fields to DropDown - Messages</description>
<language>en-us</language>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Jitbit AspNetForum</generator>
<pubDate>Sun, 03 Dec 2017 20:43:32 GMT</pubDate>
<lastBuildDate>Sun, 03 Dec 2017 20:43:32 GMT</lastBuildDate>
<item>
<link>https://www.codetrigger.com/forum/topic17-binding-foreign-key-fields-to-dropdown.aspx</link>
<title>Message from migrator</title>
<description><![CDATA[<span style="font-family:Tahoma, " sans="" serif",="" arial">Hi</span><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">If I understand you correctly, you are wondering how to write a query to lookup by foreign key, potentially to bind the results to a drop down, since MVC sample generator does not provide this facility out of the box.</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">The page </span><a href="https://web.exotechnic.com/owa/redir.aspx?C=657a8c67cd2b4c4d95ecdba35f796b2c&URL=https%3a%2f%2fwww.codetrigger.com%2fcriteriaqueryapi.aspx" target="_blank" rel="nofollow">https://www.codetrigger.com/criteriaqueryapi.aspx</a><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">has plenty of examples on how to use the CriteriaQuery Api for different types of queries.</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">If you have the value of the foreign key then its a straightforward query</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">IList&lt;BOProduct&gt; boProducts = new Criteria&lt;BOProduct&gt;().Add(Expression.Eq("Category", "Fitness")).List&lt;BOProduct&gt;();</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">gives you a list of Products based on the Category foreign key: 'Fitness'</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">There are other examples of queries using subqueries, or selection from a table based on values in other tables etc.</span><br/><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">If you are using MVC pattern, after code generation you would then extend the controller with some methods to run these custom queries and return data for populating the drop downs. Add methods similar to the generated methods, that take a foreign key value as parameter and return a list of values. This list you then bind to a html drop down list.</span><br/><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">The section 'Customising Generated Code' on the page </span><a href="https://web.exotechnic.com/owa/redir.aspx?C=657a8c67cd2b4c4d95ecdba35f796b2c&URL=https%3a%2f%2fwww.codetrigger.com%2ffeatures.aspx" target="_blank" rel="nofollow">https://www.codetrigger.com/features.aspx</a><br/><span style="font-family:Tahoma, " sans="" serif",="" arial">gives you directions on your options for customising code thats already been generated. Basically your options are either to create new files with partial classes containing the new code, or modify the generated files directly and then add them to the 'escaped files' list (Pro license version only) so that your changes do not get over-written.</span><br/><i>edited by migrator on 12/3/2017</i>]]></description>
<pubDate>Sun, 03 Dec 2017 20:43:32 GMT</pubDate>
</item>
<item>
<link>https://www.codetrigger.com/forum/topic17-binding-foreign-key-fields-to-dropdown.aspx</link>
<title>Message from migrator</title>
<description><![CDATA[<span style="font-family:Tahoma, "Sans Serif", Arial">Looking at the code generated I need guidance on how to do foreign key looks For example all the generated UI screens display the primary key, none seem to support foreign key lookups, etc</span>]]></description>
<pubDate>Sun, 03 Dec 2017 20:38:01 GMT</pubDate>
</item>
</channel>
</rss>
