查找页面控件

来源:互联网 发布:淘宝试用如何领取 编辑:程序博客网 时间:2024/06/05 06:03

根据控件名查找页面控件

        For i = 0 To dtScreenControl.Count - 1
            Dim controlFirstName = dtScreenControl(i).ControlName.Substring(0, 3)
            Dim value = dtScreenControl(i).SettingValue
            Select Case controlFirstName
                Case "chk"
                    Dim chk As CheckBox = DirectCast(Page.Master.FindControl("ContentBodyPlaceHolder").FindControl(dtScreenControl(i).ControlName), CheckBox)
                    chk.Checked = CBool(value)
                Case "ddl"
                    Dim ddl As DropDownList = DirectCast(Page.Master.FindControl("ContentBodyPlaceHolder").FindControl(dtScreenControl(i).ControlName), DropDownList)
                    ddl.SelectedValue = dtScreenControl(i).SettingValue
                Case "grb"
                    Dim grb = DirectCast(Page.Master.FindControl("ContentBodyPlaceHolder").FindControl(dtScreenControl(i).ControlName), RadioButton)
                    grb.Checked = CBool(value)
                Case "txt"
                    Dim txt = DirectCast(Page.Master.FindControl("ContentBodyPlaceHolder").FindControl(dtScreenControl(i).ControlName), TextBox)
                    txt.Text = value
            End Select

        Next

参考

http://jeanne.wankuma.com/tips/vb.net/form/findcontrol.html


 

 

0 0
原创粉丝点击