获取绑定字段名称在运行时ASP.NET [英] Getting the Bound Field Name at Run Time in ASP.NET
本文介绍了获取绑定字段名称在运行时ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个控制,一个FormView内,即使用&LT约束;%#Bind(...)%>
EX pression。在运行时,有没有办法获取该控件绑定到字段的名称。
需要明确的是,如果EX pression是<%#Bind(用户名)%>
我想返回字符串用户名
。
解决方案
广泛的调试插科打诨后,我发现这工作
<$p$p><$c$c>((System.Web.UI.WebControls.AutoGeneratedField)((System.Web.UI.WebControls.DataControlFieldCell)(e.Row.Cells[0])).ContainingField).SortEx$p$pssion在调试使用Shift + F9打开快速监视窗口的痛苦和视觉探索的事件参数
If I have a control, within a FormView, that is bound using a <% #Bind(...)%>
expression. At run time, is there any way of retrieving the name of the field the control is bound to.
To be clear, if the expression is <% #Bind("UserName") %>
I want to return the string "UserName"
.
解决方案
after messing around extensively in debug, I found this to work
((System.Web.UI.WebControls.AutoGeneratedField)((System.Web.UI.WebControls.DataControlFieldCell)(e.Row.Cells[0])).ContainingField).SortExpression
In debug use shift+F9 to open the quick watch window pain and explore your Event Argument visually
这篇关于获取绑定字段名称在运行时ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文