问题
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
回答1:
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.
回答2:
Please change the order your code is executed:
trlGroup.DataSource = gnlTreeDColl;
trlGroup.DataBind();
trlGroup.ExpandAll();
This should work.
回答3:
Change the GridView
enableCallback
property to False
.
来源:https://stackoverflow.com/questions/3862397/i-cannot-change-controls-visibility-on-c-sharp-code