Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capture the value from a text box in a formview

Status
Not open for further replies.

ola123

Technical User
Sep 16, 2005
52
JM
Morning guys,

I have a formview and i would like to capture content of a textbox within the formview and display its content in another textbox or label whenever a button is pressed.

i have tried the following:
Code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        txttest.Text = FormView1.FindControl("txtappno")

End Sub
the error i'm getting is that the "value of type system.web.UI.control cannot be converted to string"

oh i'm a newbie so any link to any material that would assist would be greatly appreciated.

thanks for the assistance in advance
 
Post questions involving ASP.Net WebForms here:
forum855. You'll get help more quickly that way.

Post questions involving VB language/syntax, VB/WinForms, VB/ConsoleApps, VB/Windows Services in the forum you are in now.
 

This code:

FormView1.FindControl("txtappno")

returns a reference to the textbox, so you are trying to assign a textbox to a string, which produces the error you are getting. Try this:

Dim t As TextBox

t = FormView1.FindControl("txtappno")

txttest.Text = t.Text



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Guys thanks a million
it worked.

RiverGuy - thanks i'll do that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top