|
-
Aug 7th, 2009, 04:29 AM
#1
Thread Starter
Addicted Member
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"
-
Aug 7th, 2009, 05:15 AM
#2
New Member
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 !!!
-
Aug 7th, 2009, 05:41 AM
#3
Thread Starter
Addicted Member
Re: Programatically reset Formview values
Same error but specifically pointing to "If TypeOf FormView7.Controls.Item(x) Is TextBox Then"
-
Aug 7th, 2009, 06:20 AM
#4
New Member
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
-
Aug 7th, 2009, 06:22 AM
#5
New Member
Re: Programatically reset Formview values
just use the above routine i sent....
remove ur for loop... and use this one instead
-
Aug 7th, 2009, 10:47 AM
#6
Thread Starter
Addicted Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|