Question: I have a partial view which has a dropdown in it and I include that partial in my page twice. Here is the dropdown.

```
<form name="sortbyformtop">
            <select onchange="sort('@querystring', this.options[this.selectedIndex].value);" name="sortbyselecttop">
                <option value=""></option>
                <option value="accommodationtype">Accommodation type</option>
                <option value="mostreviewed">Most reviewed</option>
                <option value="lowestprice">Lowest price</option>
            </select>
        </form>

```

Now, when the page loads, if the querystring contains a key `sortby` then I would like to take the value of `sortby` (which will be `accommodationtype`, `mostreviewed`, `lowestprice` i.e. the value of the options). What I'd like to do is set both dropdowns on the page to the option that matches the `sortby` query string value. I've tried lots of things but nothing is working.

Can you help?

**Edit**

I tried this but it did not work

```
$(document).ready(function () {
                $("#sortbyselecttop option").filter(function () {
                    alert($(this).text());
                    return $(this).text() == "lowestprice";
                }).first().prop("selected", true);
            });

```

Answer: 
> 
> I would like to know how to implement same thing using Workflow services as I could get the benefits of AppFabric for my workflows.
> 
> 
> 

This is pretty straight forward. You're going to have one workflow that reads the file and loops through the results using the looping activities that exist. Then, inside the loop you'll be starting up the workflow that each record needs **(the "Service")** by calling the endpoint with a `Send` activity.

Now, as for the workflow that is the Service, you're going to have a `Receive` activity at the top of the workflow that also has `CanCreateInstance` set the `true`. The everything after the `Receive` is no different than any other workflow. You may consider having a `Send` activity right after the `Receive` just to let the caller know that the Service has been started. But that's not a requirement -- the `Receive` will be required because it forces WF to build the workflow to use the `WorkflowServiceHost`.

> 
> Is there any other solutions to handle batch of records/ids? Otherwise workflow service has to be called 1000s of times just to register every record in a workflow instance which is a not a good solution.
> 
> 
> 

Are you indicating that a for a web server to receive 1000's of requests is not a good solution? Consider the fact that an IIS server can handle roughly 25-50 requests, per **instant** in time, **per core**. Now consider the fact that you're loop that's loading the workflows isn't going to average more than **maybe** 5 in that **instant** of time but probably more like 1 or 2.

I don't think the web server is going to be your issue. I've started up literally 10,000's of workflows on a server via a loop just like the one you're going to build and it didn't break a sweat.
In the spirit of the doing the simplest thing that could work, you can bring the subworkflow in as an activity to the main workflow and use a parallel for each to execute the branch for each input from your file. No extra invoking is required and the tooling supports this out of the box because all workflows are activities. Hosting the main process in a service so you can avoid contention with the rest of your IIS users, real people that they may are, might be a good idea. 

I do agree that calling IIS or a WCF service 1000's of times is not a problem though, unless you want to do it in a few seconds! 

It is important to remember that one of the good things about workflow is that it has fairly low overhead (compared to other workflow products) so you should be more concerned about what your workflow does than just the idea of launching lots of instances. The idea of batches like your example is very common.