vs2008 web express:detailsview无法隐藏新建按钮
在详细信息视图中,我想隐藏新按钮。
在页面加载时,我已通过以下代码成功完成了此操作:
dtvwMyProfile.Rows[5].Cells[0].Controls[2].Visible = false;
但是,当我完成编辑后点击取消或更新按钮时,如何隐藏“新建”按钮。
“新建”按钮不断显示。如何将其完全隐藏在屏幕上。
在某些情况下,visible 属性不断更改为 true,我如何找出该事件?
我希望能够在运行时而不是设计时完成它。
On details view, I would like to hide the new button.
On page load I have successfully done so by the following code:
dtvwMyProfile.Rows[5].Cells[0].Controls[2].Visible = false;
But how do I hide the New button when I hit cancel or update button after I am done editing.
The New button keeps showing up. How do I hide it completely from the screen.
In some event, the visible property keeps changing to true and how do i find out that event?
I want to be able to do it at run time instead of design time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不建议动态更改由DetailsView 创建的子控件的属性。
如果该按钮是由 DetailsView 本身创建的,那么您所需要做的就是将 AutoGenerateInsertButton 设置为 false,然后您可以在 Page_Load 中执行此操作。
我不建议随机选择一个页面事件并处理它。如果你这样做,那么当你改变其他东西时它很可能会再次崩溃。
Dynamically changing the properties of child controls created by the DetailsView is not recommended.
If the button is being created by the DetailsView itself then all you need to do is set
AutoGenerateInsertButton
to false and you can do that in Page_Load.I do not recommend randomly selecting a page event and handling it. If you do that then chances are it will just break again when you change something else.
也许尝试在 ModeChanged 事件处理程序中执行此操作,该事件处理程序在模式更改后触发...但是您能确保 new 始终位于位置 2 吗?您可能想通过按钮的文本或命令名称来验证按钮。
Maybe try to do that in the ModeChanged event handler, which fires after the mode changes... But can you ensure new is always at position 2? You may want to verify the button by its text or command name.