我在关闭 gridview 后按下按钮时遇到问题,然后代码正在工作,但是当我在 gridview 中按下按钮时发生错误“System.InvalidOperationException:'ModalPopupExtender1'的 TargetControlID 无效。ID 为'btn_edit'的控件找不到。” 我的代码是:
代码
autogeneratecolumns="False" allowpaging="True" PageSize="3" width="500px" ondatabound="CustomersGridView_DataBound"
runat="server" DataKeyNames="CompanyFName" CellPadding="4" ForeColor="#333333" GridLines="None ">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="CompanyFName" HeaderText="CompanyFName"
SortExpression="CompanyFName" />
<asp:BoundField DataField="CompanySName" HeaderText="CompanySName"
SortExpression="CompanySName" />
<asp:templatefield>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<pagerstyle forecolor="White"
backcolor="#666666" HorizontalAlign="Center"/>
<pagertemplate>
<table width="100%">
<tr>
<td style="width:70%">
<asp:label id="MessageLabel"
forecolor="Blue"
text="Select a page:"
runat="server"/>
<asp:dropdownlist id="PageDropDownList"
autopostback="true"
onselectedindexchanged="PageDropDownList_SelectedIndexChanged"
runat="server"/>
</td>
<td style="width:70%; text-align:right">
<asp:label id="CurrentPageLabel"
forecolor="Blue"
runat="server"/>
</td>
</tr>
</table>
</pagertemplate>
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:gridview>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/eTimeTrackLite1.mdb"
SelectCommand="SELECT [CompanyFName], [CompanySName] FROM [Companies]">
</asp:AccessDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Panel ID="Panel1" runat="server" BackColor="#990099" Height="146px"
Width="403px">
<asp:Button ID="Button2" runat="server" Text="Button" />
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btn_edit" PopupControlID="Panel1" CancelControlID="Button2" X="280" Y="220">
<Animations>
<OnShowing>
<FadeIn Duration=".5" Fps="40" />
</OnShowing>
<OnShown>
<FadeIn Duration=".5" Fps="40" />
</OnShown>
<%-- neither animation works from code-behind --%>
<OnHiding>
<FadeOut Duration=".5" Fps="40" />
</OnHiding>
<OnHidden>
<FadeOut Duration=".5" Fps="40" />
</OnHidden>
</Animations>
</asp:ModalPopupExtender>