How to bind colors to controls in an formview
Hi All,
It took me hours of searching the net not to find the solution but managed to find the solution by experiment!
You have a control within a formview and the Forecolor is bound to it.
Your sql table has a field called "Forecolor" with the value "RED" for type = text.
Bind the control with the following;
ForeColor='<%# system.drawing.color.fromname(Eval("ForeColor")) %>'
This works for anything with color.
FromName takes the "Red" string and converts to proper system.drawing.color!
Something else;
The Borderstyle = int
so for a solid border enter 1
Bind the control with the following;
BorderStyle='<%# Eval("BorderStyle") %>'
If you want to find the other values for borderstyle then -
"Me.Button1.BorderStyle = BorderStyle.Dotted" mouse over BorderStyle.Dotted to get int value of 2. Get my drift!
I hope this is of any help to anyone searching for a quick and easy answer.
Regards
Paul
|