|
Subject:
|
Retrieving a value from a control within FormView
|
|
Posted By:
|
tbrux
|
Post Date:
|
8/7/2006 2:45:20 PM
|
Hello,
I am trying to retrieve a value for one of the controls within the FormView on my ASP.net 2.0 webpage. My code is:
Protected Sub FormView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBinding If FormView1.CurrentMode = FormViewMode.Edit Then If Page.IsPostBack Then Dim txtTextBoxValue As New TextBox txtTextBoxValue = _ CType(FormView1.FindControl("JobTextBox"), TextBox) Response.Write(txtTextBoxValue) End If End If End Sub
This code is firing except that it is returning me a value of: System.Web.UL.WebControls.TextBox
I want what's actually stored in the textbox. Anybody have any suggestions or can tell me what I am doing wrong?
Thank you--much appreciated...
tbrux
|
|
Reply By:
|
Imar
|
Reply Date:
|
8/7/2006 2:49:20 PM
|
You need the control's Text property. The code you have now will call ToString instead....
Response.Write(txtTextBoxValue.Text)
By the way, you don't need to new up the control first:
Dim txtTextBoxValue As New TextBox txtTextBoxValue = _ CType(FormView1.FindControl("JobTextBox"), TextBox)
Saves a few CPU cycles....
Imar --------------------------------------- Imar Spaanjaars Everyone is unique, except for me. Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004 Want to be my colleague? Then check out this post.
|
|
Reply By:
|
tbrux
|
Reply Date:
|
8/7/2006 2:54:55 PM
|
Thank you so much--it works! Teri
|