Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 31st, 2006, 02:00 AM
Registered User
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.


Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView - access DropDownList controls kgaughan ASP.NET 2.0 Basics 0 July 29th, 2008 01:40 PM
Validation controls and FormView templates bpdsmark BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 September 28th, 2006 08:56 AM
Accessing Controls in FormView cryspe ASP.NET 2.0 Basics 0 May 16th, 2006 03:59 PM
changing colors in standards controls gbianchi Pro VB 6 6 September 22nd, 2005 03:11 PM
Changing colors of numerous disabled controls mariak Pro VB.NET 2002/2003 3 February 26th, 2004 06:18 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.