访问占位符上的动态控件属性 [英] Accessing Dynamic Control Properties On a Placeholder

查看:95
本文介绍了访问占位符上的动态控件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
如何在vb.net中的占位符上访问动态控件的属性(例如,文本框,下拉列表).我有要运行的查询字符串,但是控件的数量和类型取决于查询字符串的参数.我已经成功创建了控件,但是无法访问它们的属性.当我遍历占位符时,找不到我的控件.

请我帮忙.
预先感谢.

HI
How do I access the properties of a dynamic controls(eg. textbox,dropdownlist) on a place holder in vb.net. I have strings of queries to run but the number and type of control depends on the parameter of the Query string. I have successfully created the controls but can not access their properties. When I loop through the place holder my control are not found.

Please I need a help.
Thanks in advance.

推荐答案

奇怪的是,这只是作为" ^ ]''今天!这可能很有帮助.
Oddly, this just came up as the ''Featured Article[^]'' for today! This might be quite helpful.


函数getPameterValue(ByVal ParentCtrl作为对象,ByVal CtrName作为字符串)作为String
昏暗的childCtrl作为控件
getPameterValue ="

对于ParentCtrl.Controls''ParamPlaceHolder
中的每个childCtrl 如果TypeOf childCtrl是TextBox,则
如果childCtrl.ID = CtrName,则''或childCtrl.UniqueID = CtrName
getPameterValue =''"和CType(childCtrl,TextBox).Text和""
如果结束

ElseIf TypeOf childCtrl是DropDownList然后
如果childCtrl.ID = CtrName,则''或childCtrl.UniqueID = CtrName
getPameterValue =''"&CType(childCtrl,DropDownList).SelectedItem.Value.ToString&''"
如果结束

如果结束

下一个孩子Ctrl

返回getPameterValue
结束功能
Function getPameterValue(ByVal ParentCtrl As Object, ByVal CtrName As String) As String
Dim childCtrl As Control
getPameterValue = ""

For Each childCtrl In ParentCtrl.Controls ''ParamPlaceHolder
If TypeOf childCtrl Is TextBox Then
If childCtrl.ID = CtrName Then ''Or childCtrl.UniqueID = CtrName
getPameterValue = "''" & CType(childCtrl, TextBox).Text & "''"
End If

ElseIf TypeOf childCtrl Is DropDownList Then
If childCtrl.ID = CtrName Then ''Or childCtrl.UniqueID = CtrName
getPameterValue = "''" & CType(childCtrl, DropDownList).SelectedItem.Value.ToString & "''"
End If

End If

Next childCtrl

Return getPameterValue
End Function


这篇关于访问占位符上的动态控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆