Back to
Latest changes:
2020/01/13 19:15

This is an old revision of the document!

Dynamically populating lists by information from other conditions (WebForms)

We will discuss this problem and its solution by example. Let's say the user can define a condition with city e.g. “City name is equal to LA”. But if the user has already selected a country (or a few countries) in one of their condition list then the list of cities available for indicated condition must be filled with only the cities in the selected countries.

To implement such functionality you just need to check if the attribute our list depends on is already set in one of conditions and get its value. We use GetOneValueForAttr() method to do it.

After that we just use the value we got when populating our list.

So, here our code sample.

protected void QueryPanel1_ListRequest(object sender,
                   Korzh.EasyQuery.WebControls.ListRequestEventArgs e) {
    EntityAttr countryAttr =
        query.Model.EntityRoot.FindAttribute(EntityAttrProp.Expression, "Customers.Country");
    if (e.ListName == "RegionList") {
        string country = query.GetOneValueForAttr(countryAttr);
        if (country == "Canada") { 
            e.ListItems.Add("British Columbia", "BC");
            e.ListItems.Add("Quebec", "Quebec");
        else if (country == "USA") {
            e.ListItems.Add("California", "CA");
            e.ListItems.Add("Colorado", "CO");
            e.ListItems.Add("Oregon", "OR");
            e.ListItems.Add("Washington", "WA");


, 2013/12/17 23:22
Looking at your EQWebDemoVB2010Net40, which I modified to use an XML from my db, and trying to figure out how to do this, with (3) select lists. Is it possible to get a VB example? I have an initial query in the XML for my first value, but when I select something from it, it never goes into the qp1_ListRequest to check the value. Sure could use some assistance with this.
, 2013/12/19 16:55
We've added an example of such approach into our WebDemoVB sample project (it's included into EasyQuery installation package).
Try to run it and then add condition with Customer Country e.g. "Customer Country is equal to Germany"
Now if you add another condition with Customer City attribute you will see the list of German cities only.
Enter your comment: