I'm building a web application in ArcGIS Server for .net and I want to create query task for each layer so that each query depends on the previous result query task, how can I do that?
You could create a page method to set up each query and pass it the results of the previous query. When the user makes a selection, call the page method with the selected value. In the page method, code the query and return the results to the second drop down.
Is that the kind of process you're looking for? Or do you need the actual code?
If I understand what you mean,you need to select features drom previous selection,for example if the first query select 1000 features in layer1,you need the second query in this layer,selects from that 1000 features.If this is right,maybe this is a solution for it:
1.Creating a table containing this columns at least: UserName|SessionId,LayerId,FeatureId,TimeStamp,(For example TBSel table)
2.Create an extension,overload tha SelectionChanged event of IActivatedView,and in the callback method,if there is new selections in that layer,(Can delete previous records corresponding to layerId and UserName and) insert new records for new selections in that layer(or all layers) TimeStamp column must be filled with the system time.
3.Combine each query for that layer with this phrase:
WhereClause+=" AND FeatureId in (SELECT FeatureId FROM TBSel WHERE UserName='MyUser' AND LayerId='MyLayerId' AND TimeStamp=(SELECT Max(TimeStamp) FROM TBSel WHERE UserName='MyUser' AND LayerId='MyLayerId' ))
in this way,selection from that layer is from most previous selection(or result of previous query),even you can make this optional,and if user want to enable this option,you will change WhereClause of the query filter.
Hope I could understand what you mean and it helps.