Programatically reset Formview values
Does anyone know how to programically clear the data from a form view using vb.net. I have so far come up with the following:
Code:
Dim x
For x = 0 To Me.Controls.Count - 1
'if it is a text box then clear it
If TypeOf FormView7.Controls.Item(x) Is TextBox Then
Dim text As TextBox = FormView7.Controls.Item(x)
text.Text = ""
End If
Next
But i get the error "Specified argument was out of the range of valid values.
Parameter name: index"
Re: Programatically reset Formview values
try
Code:
If TypeOf FormView7.Controls.Item(x) Is TextBox Then
dim mm as textbox = directcast (formview7.control.item(x), textbox)
mm.text = ""
End If
this should help !!!
Re: Programatically reset Formview values
Same error but specifically pointing to "If TypeOf FormView7.Controls.Item(x) Is TextBox Then"
Re: Programatically reset Formview values
try this
Code:
Dim ctrl As Control
For Each ctrl In formview7.Controls
If TypeOf ctrl Is textbox Then
Dim txt1 As textbox
txt1 = DirectCast(ctrl, textbox)
txt1.text = ""
End If
Re: Programatically reset Formview values
just use the above routine i sent....
remove ur for loop... and use this one instead
Re: Programatically reset Formview values
Still not working, i would rather hoping there would be a formview7.reset or something similar heres the code i have at present with thanks to your asssistance:
Code:
Dim ctrl As Control
For Each ctrl In FormView7.Controls
If TypeOf ctrl Is TextBox Then
Dim txt1 As TextBox
txt1 = DirectCast(ctrl, TextBox)
txt1.Text = ""
End If
Next