开发者

find controls that have been selected in asp.net

Hi I'm building a web application fo开发者_StackOverflowr a client with some unique controls and criteria. One page involves a detailed search function consisting of about 100 combo boxes and listboxes. What I am trying to do is do a foreach(control that has been changed/selected){} and feed it into a function to generate a query. There are 100 but the user may only use three for a particular search ?

I know there must be a way to do this. Thanks in advance for the help


Well you can use something like:

List<Control> list = new List<Control>();

public void ControlRecursive(Control Root)
    {
        if(typeof(ComboBox) == Root.GetType() && ((ComboBox)Root).Checked)
            list.Add(Root);
        else if (Root is RadListBox)
        {
            // deal with RadListBox here
        }
        // if all your other types
        // ...

        foreach (Control Ctl in Root.Controls)
            ControlRecursive(Ctl);
    }

Then call this with ControlRecursive(form1);


You could have a javascript function associated with onchange / select for each of your controls and then add to a javascript array the item that has been selected. Then you can pass that array to your query generation to know what variables to pick up for your search.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜