Formview FindControl conversion to c#

S

sck10

Hello,

I am trying to get the value of a control in a FormView. In vb, I would use
the following:

e.NewValues("ServiceIdeaQ01") =
CType(this.fvServiceIdea.FindControl("lblServiceIdeaQ01Edit"), Label).Text

For c#, what I have found on the web is the following:

Label ServiceIdeaQ01Label =
(Label)this.fvServiceIdea.Row.FindControl("lblServiceIdeaQ02Item");
e.NewValues("ServiceIdeaQ01") = ServiceIdeaQ01Label.Text;

Is there a way in c# to do the same thing with one line? For some reason, I
can't get the "Text" argument:

(Label)this.fvServiceIdea.Row.FindControl("lblServiceIdeaQ02Item").Text;

Thanks, sck10
 
M

Mark Rae

Is there a way in c# to do the same thing with one line? For some reason,
I can't get the "Text" argument:

(Label)this.fvServiceIdea.Row.FindControl("lblServiceIdeaQ02Item").Text;

((Label)this.fvServiceIdea.Row.FindControl("lblServiceIdeaQ02Item")).Text;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top