HEllo, I need to dynamically activate fields in a page according to the service that is going to be executed...

Let me explain:

There's a page with all the possible fields and a ListBox with all the selected services to be executed, then when the user selects which service to execute (change a car plate, for example), then I need to activate only the field(s) that the service require... (The realationship between Services and Fields are stored in a database).

public void CheckAll(int pService_Id, Control pPage)

    foreach (Control control in pPage.Controls)
        busExecutaServico vExecuta = new busExecutaServico();

        if (vExecuta.EnableField(control.ID.ToString(), Convert.ToInt32(listBoxServices.SelectedValue)))
            switch (control.GetType().ToString())
                case "TextBox":
                    TextBox controleText = (TextBox)Page.FindControl(control.ID.ToString());
                    controleText.Enabled = true;

Note that busExecutaServico is the class which contains the method (EnableField) for checking if the selected item matches any field on the database..

I can't seem to get the control.ID.ToString() to work properly (the ID always comes as NULL)

If anyone can help me solve this, or if there's another way (even if it's completely different from what i'm trying), it would be of great help. thanks

This article has been dead for over six months. Start a new discussion instead.