我无法更改控件在 C# 代码上的可见性
我想更改 c# 上的控件可见性,但没有任何反应。这些控件位于 AspxPopupControl 中,其中 3 个在设计时隐藏,其中 1 个可见。我使用此代码来显示它们
if (paramType == "Grup")
{
gv_Answers.Visible = false;
trlGroup.Visible = true;
chkShowItems.Visible = true;
}
else
{
gv_Answers.Visible = true;
trlGroup.Visible = false;
chkShowItems.Visible = false;
}
此代码位于 gridview 的 CustomCallBack 事件中。所以我现在不知道该怎么办。这是一项简单的任务,但我无法完成。
谢谢你的帮助
I want to change controls visibility on c#, but nothing happens. The controls are in an AspxPopupControl and 3 of them are hidden in design time, 1 of them is visible. I use this code to visible them
if (paramType == "Grup")
{
gv_Answers.Visible = false;
trlGroup.Visible = true;
chkShowItems.Visible = true;
}
else
{
gv_Answers.Visible = true;
trlGroup.Visible = false;
chkShowItems.Visible = false;
}
This code is in a CustomCallBack event of a gridview. So i don't know what to do from this point. It's an easy task but i couldn't handle it.
Thanks for you helps
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此问题的原因是您正在 ASPxGridView 回调中更改控件的可见性。回调响应仅包含有关发起回调的控件及其子控件的信息。由于 ASPxPopupControl 不是 GridView 的一部分,因此出现了问题。最简单的解决方案是在 PostBack 事件而不是回调中实现此代码。在这种情况下,一切都会正常工作。
The cause of this problem is that you are changing the control's visibility within the ASPxGridView's callback. The callback response contains only the information about control who initiated the callback and its child controls. Since the ASPxPopupControl is not a part of the GridView, the problem appears. The easiest solution is to implement this code within a PostBack event, not a callback. In this case, everything will work correctly.
请更改代码的执行顺序:
这应该可行。
Please change the order your code is executed:
This should work.
将
GridView
enableCallback
属性更改为False
。Change the
GridView
enableCallback
property toFalse
.