我想在 ASP 面板中添加一个可扩展的 asp 网格,我想通过更改面板的可见真/假选项使其可见/不可见。
如果我删除 asp:Panel ID="test1",该站点将打开,可扩展的 gridview 工作没有问题。
在面板中添加代码后,我会收到一条错误消息:
Expression expected.
Source Error:
Line 46: <a href="JavaScript:divexpandcollapse('div<%# Eval("reporting_group") %>');">
任何人都可以解释为什么会发生这种情况以及如何避免它。我也尝试过具有相同结果的 Ajax TabContainer。
请参阅下面的代码。
<script language="javascript" type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "block"; img.src = "Images/Icons/minus.jpg";
} else { div.style.display = "none"; img.src = "Images/Icons/plus.jpg"; }
}</script>
<asp:Panel ID="test1" runat="server">
Panel 1<br />
<asp:UpdatePanel ID="UP_TabContainer" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GV_SL" runat="server" AutoGenerateColumns="False"
DataSourceID="SQL_Weekly" OnRowCommand="GV_SL_RowCommand"
OnRowDataBound="gvUserInfo_RowDataBound">
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("reporting_group") %>');">
<img id="imgdiv<%# Eval("reporting_group") %>" width="15px" border="0" src="Images/Icons/plus.jpg" />
</a>
</ItemTemplate><ItemStyle Width="40px" />
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Group" SortExpression="name" />
<asp:BoundField DataField="ASL" HeaderText="SL% Act" ReadOnly="True" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td >
<div ID='div<%# Eval("reporting_group") %>' style="display: none; position: relative;
left: 15px; overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Metric"
HeaderText=" "/>
<asp:BoundField DataField="Actual" HeaderText="Actual" />
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SQL_Weekly" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand=" SQL QUERY" <SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SQL_Group" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand=" SQL QUERY" ></asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DateSelection"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<br />
</asp:Panel>