|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reading / Modifying FormView Child Controls at Runtimeam trying to do in my last post. I have created a FormView with lots of label controls. Depending on certain other values obtained at runtime, I want to color-code a label inside the form-view. For example, if the text of Label1 = "Y" I want to set the ForeColor property of Label7 (inside the FormView control) to Green. I've tried: FormView1.Label7.ForeColor = "green" but I get an error. I've tried: FormView.FindControl("Label7").ForeColor = "green" but I get an error. I know what I want to do, and I think I've articulated it pretty clearly in this post. I'm just not aware of HOW to accomplish this. Any help would be greatly appreciated. Scott (Can you tell I'm a newb?) You have to a Color enum when referencing color in this context. So, try
this: FormView1.Label7.ForeColor = Color.Green -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Scott at Cedar Creek" <ScottatCedarCr***@discussions.microsoft.com> wrote in message news:F417E203-C86B-4666-AF5B-FDC225380779@microsoft.com... > Please excuse me for reposting, I am not sure I correctly articulated what > I > am trying to do in my last post. > > I have created a FormView with lots of label controls. Depending on > certain > other values obtained at runtime, I want to color-code a label inside the > form-view. For example, if the text of Label1 = "Y" I want to set the > ForeColor property of Label7 (inside the FormView control) to Green. > > I've tried: > > FormView1.Label7.ForeColor = "green" > but I get an error. > > I've tried: > > FormView.FindControl("Label7").ForeColor = "green" > but I get an error. > > I know what I want to do, and I think I've articulated it pretty clearly > in > this post. I'm just not aware of HOW to accomplish this. Any help would > be > greatly appreciated. > > Scott (Can you tell I'm a newb?) Hello Scott,
The FormView.Row represents the row in the FormView. You can access your Label control using the FindControls like this: Dim row As FormViewRow = FormView1.Row Dim myLabel as Label dim cntrl as Control = row.FindControl("Label7") If Not cntrl Is Nothing Then 'if you found the control 'explicitly converting the found object to a Label Control myLabel = Ctype(cntrl, Label) myLabel.cssClass = "GreenClassStyle" End If --- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com Show quoteHide quote "Scott at Cedar Creek" wrote: > Please excuse me for reposting, I am not sure I correctly articulated what I > am trying to do in my last post. > > I have created a FormView with lots of label controls. Depending on certain > other values obtained at runtime, I want to color-code a label inside the > form-view. For example, if the text of Label1 = "Y" I want to set the > ForeColor property of Label7 (inside the FormView control) to Green. > > I've tried: > > FormView1.Label7.ForeColor = "green" > but I get an error. > > I've tried: > > FormView.FindControl("Label7").ForeColor = "green" > but I get an error. > > I know what I want to do, and I think I've articulated it pretty clearly in > this post. I'm just not aware of HOW to accomplish this. Any help would be > greatly appreciated. > > Scott (Can you tell I'm a newb?)
asp.net 2.0 treeview control - very slow
treeview asp.net 2.0 Menu Control - SubItem Shadows TreeView with custom HierarchicalDataSourceControl Telling weither the control is in design time or on a web page How do I reference or change formview child controls in code? Gridview hypterlink colomn to popup a new window DataGrid event handlers are being lost during re-compile how to mention the date range in the calendar control Calendar control question |
|||||||||||||||||||||||