From: David C on
Is there a way to loop through all TextBox controls of a FormView and blank
them out? Thanks.

David


From: Mr. Arnold on
David C wrote:
> Is there a way to loop through all TextBox controls of a FormView and blank
> them out? Thanks.
>
> David
>


Yes, you can loop through all the controls on the Web from, check what
type of UI control object it is, and address the properties of the UI
control object.

ctrl.Text = "" if the control has a Text property, as an example.

http://dotnetcoderoom.wordpress.com/2009/03/07/traverse-loop-through-all-form-controls-in-aspnet/

From: David C on

"Mr. Arnold" <Arnold(a)Arnold.com> wrote in message
news:%23W3oDQUaKHA.1592(a)TK2MSFTNGP06.phx.gbl...
> David C wrote:
>> Is there a way to loop through all TextBox controls of a FormView and
>> blank them out? Thanks.
>>
>> David
>
>
> Yes, you can loop through all the controls on the Web from, check what
> type of UI control object it is, and address the properties of the UI
> control object.
>
> ctrl.Text = "" if the control has a Text property, as an example.
>
> http://dotnetcoderoom.wordpress.com/2009/03/07/traverse-loop-through-all-form-controls-in-aspnet/

I tried the link (it was in C# and I use VB) and created the sub below, but
it does not seem to work as after running it the controls still have data.
Can you see any problems? Thanks.

David

Private Sub ClearForm()
Dim fv As FormView = fvPeople
Dim tb As TextBox
For Each ctrl As System.Web.UI.Control In fvPeople.Controls
If TypeOf ctrl Is TextBox Then
tb = ctrl
tb.Text = ""
End If
Next
End Sub


From: Mr. Arnold on
David C wrote:
> "Mr. Arnold" <Arnold(a)Arnold.com> wrote in message
> news:%23W3oDQUaKHA.1592(a)TK2MSFTNGP06.phx.gbl...
>> David C wrote:
>>> Is there a way to loop through all TextBox controls of a FormView and
>>> blank them out? Thanks.
>>>
>>> David
>>
>> Yes, you can loop through all the controls on the Web from, check what
>> type of UI control object it is, and address the properties of the UI
>> control object.
>>
>> ctrl.Text = "" if the control has a Text property, as an example.
>>
>> http://dotnetcoderoom.wordpress.com/2009/03/07/traverse-loop-through-all-form-controls-in-aspnet/
>
> I tried the link (it was in C# and I use VB) and created the sub below, but
> it does not seem to work as after running it the controls still have data.
> Can you see any problems? Thanks.
>
> David
>
> Private Sub ClearForm()
> Dim fv As FormView = fvPeople
> Dim tb As TextBox
> For Each ctrl As System.Web.UI.Control In fvPeople.Controls
> If TypeOf ctrl Is TextBox Then
> tb = ctrl
> tb.Text = ""
> End If
> Next
> End Sub
>
>

I mislead you. The example I gave you was loop on a Web form not a FormView.


You may still need a loop using the FormView.FindControl.

http://geekswithblogs.net/azamsharp/archive/2006/05/22/79294.aspx

HTH
From: David C on

"Mr. Arnold" <Arnold(a)Arnold.com> wrote in message
news:eqy67vUaKHA.5544(a)TK2MSFTNGP02.phx.gbl...
> David C wrote:
>> "Mr. Arnold" <Arnold(a)Arnold.com> wrote in message
>> news:%23W3oDQUaKHA.1592(a)TK2MSFTNGP06.phx.gbl...
>>> David C wrote:
>>>> Is there a way to loop through all TextBox controls of a FormView and
>>>> blank them out? Thanks.
>>>>
>>>> David
>>>
>>> Yes, you can loop through all the controls on the Web from, check what
>>> type of UI control object it is, and address the properties of the UI
>>> control object.
>>>
>>> ctrl.Text = "" if the control has a Text property, as an example.
>>>
>>> http://dotnetcoderoom.wordpress.com/2009/03/07/traverse-loop-through-all-form-controls-in-aspnet/
>>
>> I tried the link (it was in C# and I use VB) and created the sub below,
>> but it does not seem to work as after running it the controls still have
>> data. Can you see any problems? Thanks.
>>
>> David
>>
>> Private Sub ClearForm()
>> Dim fv As FormView = fvPeople
>> Dim tb As TextBox
>> For Each ctrl As System.Web.UI.Control In fvPeople.Controls
>> If TypeOf ctrl Is TextBox Then
>> tb = ctrl
>> tb.Text = ""
>> End If
>> Next
>> End Sub
>
> I mislead you. The example I gave you was loop on a Web form not a
> FormView.
>
>
> You may still need a loop using the FormView.FindControl.
>
> http://geekswithblogs.net/azamsharp/archive/2006/05/22/79294.aspx
>
> HTH

Sorry, this does not help me. I know how to loop through a single control
like a listbox. I need to loop through all controls in a FormView. Thanks.

David


 |  Next  |  Last
Pages: 1 2
Prev: Find Control in Silverlight
Next: gridview in gridview