我正在尝试使用以下代码以编程方式隐藏整个 div:
System.Web.UI.Control divMask = (System.Web.UI.Control)this.Page.FindControl("urinaDiv");
System.Web.UI.HtmlControls.HtmlGenericControl htmlCtrl = (System.Web.UI.HtmlControls.HtmlGenericControl)divMask;
htmlCtrl.Attributes["Visible"] = "false";
这是div:
<div id="urinaDiv" sytle="width: 600px" runat="server">
<asp:Label ID="relatorioUrinaLabel" runat="server" Text="Relatórios Urina"></asp:Label>
<br />
<br />
<asp:GridView ID="urinasGridview" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource3">
<Columns>
<asp:BoundField DataField="idUtente" HeaderText="IDUten" SortExpression="idUtente" />
<asp:BoundField DataField="nome" HeaderText="Nome" SortExpression="nome" />
<asp:BoundField DataField="apelido" HeaderText="Apelido" SortExpression="apelido" />
<asp:BoundField DataField="data" HeaderText="Data" SortExpression="data" />
<asp:BoundField DataField="idUtenteMarcacao" HeaderText="idUtenteMarcacao" SortExpression="idUtenteMarcacao" visible="false"/>
<asp:BoundField DataField="densidade" HeaderText="Densidade" SortExpression="densidade" />
<asp:BoundField DataField="ph" HeaderText="pH" SortExpression="ph" />
<asp:BoundField DataField="glicose" HeaderText="Glicose" SortExpression="glicose" />
<asp:BoundField DataField="proteinas" HeaderText="Proteínas" SortExpression="proteinas" />
<asp:BoundField DataField="limitacoes" HeaderText="Limitcações" SortExpression="limitacoes" />
<asp:BoundField DataField="observacoes" HeaderText="Obs." SortExpression="observacoes" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server" SelectMethod="getRelatoriosUrina"
TypeName="BusinessLogicLayer.Lab_Manager" ></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource6" runat="server" SelectMethod="getRelatoriosUrinaUtente"
TypeName="BusinessLogicLayer.Lab_Manager" OnSelecting="urinaSelecting" ><SelectParameters>
<asp:Parameter Name="idUtente" /></SelectParameters></asp:ObjectDataSource>
<br />
<br />
</div>
但我收到以下错误:
无法加载视图状态。正在加载视图状态的控制树必须与在先前请求期间用于保存视图状态的控制树匹配。例如,当动态添加控件时,回发期间添加的控件必须与初始请求期间添加的控件的类型和位置相匹配。
非常感谢提前!!