jfsedlar3rd
asked on
Change control state from db value.
I am working on an ASP.NET site. My site has a complex model for the state of the controls depending on the status the record is in. I have multiple AD groups linked to the respective status that they can access. I am adding another layer to the linker table which will store an ID of a linker table that holds the Control and the state. From code how can I enable,disable and readonly the control without building a huge case statement which contains every control name. Is there a class model i can use that will take the name of the control and the state i want the control to be in from the db?
ASKER
I think I can make this work thank you. But I will still have to have a case statement for control type.
Select Caset db.ControlType
Case TextBox
CType(Page.FindControl("Co ntrolName" ), TextBox).Visible = False
Case Button
CType(Page.FindControl("Co ntrolName" ), Button).Visible = False
Case DropDownList
CType(Page.FindControl("Co ntrolName" ), DropDownList).Visible = False
End Select
Select Caset db.ControlType
Case TextBox
CType(Page.FindControl("Co
Case Button
CType(Page.FindControl("Co
Case DropDownList
CType(Page.FindControl("Co
End Select
ASKER
Actually that wont work cause the property e.g. visible,readonly etc can change too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn.microsoft.com/en-us/library/31hxzsdw.aspx
Then for each database record, you call findcontrol using the value from your data row's id column and set the appropriate value on that control.