Home All Groups Group Topic Archive Search About

How do I reference or change formview child controls in code?

Author
2 Feb 2006 8:50 PM
Scott at Cedar Creek
I have a FormView control (which, by the way, is VERY cool) that contains a
bunch of controls inside it.  One of them is a label called "Status".  I
would like this label to be one of several colors, depending on its value.  I
was going to set up a "SELECT CASE" in my Page_Load code, but I can't seem to
figure out how to reference the control.  I'm pretty sure it's
FormView1.Something.Something.Something("Status") but I don't know what the
"something"s are.  Can anyone fill in the blanks for me?  Thanks in advance!
--Scott

ps. I've also tried to search for appropriate documentation in Help, but
apparently I need training in how to find it.  It's GOT to be out there, but
I sure could use help in finding it.

Author
3 Feb 2006 5:13 AM
Christopher Reed
Use FormView1.FindControl("Status").
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quoteHide quote
"Scott at Cedar Creek" <ScottatCedarCr***@discussions.microsoft.com> wrote
in message news:D418F91A-F2D5-40E5-9407-8B8A35B55E36@microsoft.com...
>I have a FormView control (which, by the way, is VERY cool) that contains a
> bunch of controls inside it.  One of them is a label called "Status".  I
> would like this label to be one of several colors, depending on its value.
> I
> was going to set up a "SELECT CASE" in my Page_Load code, but I can't seem
> to
> figure out how to reference the control.  I'm pretty sure it's
> FormView1.Something.Something.Something("Status") but I don't know what
> the
> "something"s are.  Can anyone fill in the blanks for me?  Thanks in
> advance!
> --Scott
>
> ps. I've also tried to search for appropriate documentation in Help, but
> apparently I need training in how to find it.  It's GOT to be out there,
> but
> I sure could use help in finding it.
Author
3 Feb 2006 7:50 PM
Scott at Cedar Creek
I'm not exactly sure HOW to use FormView1.FindControl("Status").

Would I do it like this?

FormView1.FindControl("Status").Text = "NewText"
FormView1.FindControl("Status").ForeColor = "Red"
FormView1.FindControl("Status").Visible = True

I'm trying stuff like this, and VS isn't liking it.  Try as I might (I'm
feeling VERY stupid right now), I cannot find any documentation of any
examples of this.  I sure would appreciate it if someone who is smarter than
me (nearly all of you out there qualify!) would help me out here. I'm
overwhelmed by the .Net learning curve. 

Show quoteHide quote
"Christopher Reed" wrote:

> Use FormView1.FindControl("Status").
Author
4 Feb 2006 1:06 AM
Christopher Reed
Assuming that you're using VB (so forgive me if my syntax is goofy because I
primarily use C#):
In Page_Load:

Dim Status As Label
Status = CType(FormView1.FindControl("Status"), Label)

Status.Text = "NewText"
Status.ForeColor = Color.Red
Status.Visible = True

etc., etc., etc.

You might spend some time looking at the QuickStart Tutorials.  You can find
them at www.asp.net .
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quoteHide quote
"Scott at Cedar Creek" <ScottatCedarCr***@discussions.microsoft.com> wrote
in message news:042D2860-E3B4-4129-A31D-46763DD3B4F9@microsoft.com...
> I'm not exactly sure HOW to use FormView1.FindControl("Status").
>
> Would I do it like this?
>
> FormView1.FindControl("Status").Text = "NewText"
> FormView1.FindControl("Status").ForeColor = "Red"
> FormView1.FindControl("Status").Visible = True
>
> I'm trying stuff like this, and VS isn't liking it.  Try as I might (I'm
> feeling VERY stupid right now), I cannot find any documentation of any
> examples of this.  I sure would appreciate it if someone who is smarter
> than
> me (nearly all of you out there qualify!) would help me out here. I'm
> overwhelmed by the .Net learning curve.
>
> "Christopher Reed" wrote:
>
>> Use FormView1.FindControl("Status").
>