Getting textbox value from FormView EditTemplate

Skidmerc

New member
Joined
Jun 20, 2006
Messages
2
Programming Experience
Beginner
Hi there, quite new to all this.

I have a formview on a page with some textboxes.

The textbox I want to get the value of is bound in the EditTemplate to a datetime field, and is called tbxExpiry.
The form is called frmPersonal.

I have a button at the bottom of the form with in the OnCLick event I want to take the value of the textbox and add a year to it.

I've tried:

Dim box1 As TextBox = CType(Me.FindControl("tbxExpiry"), TextBox)
MsgBox(box1.Text)

to get the value at least, but it gives "Object reference not set to an instance of an object.", and doesnt work.
I'm struggling a fair bit.

Does anyone know the best way to go about this?
 
This code doesn't work

Dim txt As TextBox
txt= CType(frmPersonal.Row.FindControl("tbxExpiry"), TextBox)

MsgBox(txt.Text)



This one does

Dim lbl As label
lbl = CType(frmPersonal.Row.FindControl("lblExpiry"), label)

MsgBox(lbl.Text)



It can read the value from the label, but not the textbox?
This doesn't make sense to me?
 
Back
Top