指引网

当前位置: 主页 > 编程开发 > ASP >

Web页面中遍历TextBox(或其它控件)的方法

来源:网络 作者:佚名 点击: 时间:2017-06-22 20:41
[摘要] Dim objTextBox As New TextBox For Each MainControl As Control In Page.Controls For Each objControl As Control In MainControl.Controls If objControl.GetType.ToString = System.Web.UI.WebControls.TextBox Then objTextBox = objControl End If Nex
Dim objTextBox As New TextBox
For Each MainControl As Control In Page.Controls
For Each objControl As Control In MainControl.Controls
If objControl.GetType.ToString = "System.Web.UI.WebControls.TextBox" Then
objTextBox = objControl
End If
Next
Next
注释:1.采用2层循环,是因为Textbox及其它控件,是Page.Controls中某控件的子控件。
2.采用遍历Textbox的方法,可以很方便的把数据库中的对应数据填写到对应的Textbox中。

------分隔线----------------------------