在 FormView 内的面板内找到一个文本框
表单视图有超过 1 个面板。我的文本框位于第一个面板中。如果我使用这个
TextBox myTxtBox = (TextBox)myformView.Row.FindControl("pnlID").FindControl("mytextbox"); <- does not work
Panel mypanel = (Panel)myformView.Row.FindControl("pnlID"); <- this works
TextBox myTxtBox = (TextBox) FindControlRecursive(mypanel,'mytextbox'); <-- this does not work
有人可以帮忙吗?作为附带问题,我使用了一个函数 FindControlIterative 但我不知道LinkedList 包含哪些引用
The formview has more than 1 Panels. My textbox is in the first panel. If I use this
TextBox myTxtBox = (TextBox)myformView.Row.FindControl("pnlID").FindControl("mytextbox"); <- does not work
Panel mypanel = (Panel)myformView.Row.FindControl("pnlID"); <- this works
TextBox myTxtBox = (TextBox) FindControlRecursive(mypanel,'mytextbox'); <-- this does not work
Can someone help? As as side question, I used a function FindControlIterative but I do not know which references to include for LinkedList
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下内容对我有用:
标记
代码隐藏
The following works for me:
Markup
Code behind
我的回答:@jdavies 解决方案是正确的。我将错误的控制传递给了该函数。我意识到我的 formView1 实际上位于另一个面板内,因此后台代码无法直接看到 formview。
My answer: @jdavies solution is right. I was passing the wrong control to the function. I realized my formView1 was actually inside another panel, thus formview was not directly visible to code behind.