我在模板字段中使用了面板,当我勾选复选框时它会消失。
我试过修理它但仍然消失了。代码在调试时运行良好,但显然不是。如果可以的话请帮忙。我已经花了很多时间在它上面。
代码:
<asp:TemplateField HeaderText='Finalized ?'>
<ItemTemplate>
<asp:LinkButton ID="btnFinalizedRecord" OnClick="btnFinalizedRecord_Click" runat="server" Text='<%# Convert.ToBoolean(Eval("IsFinalized")) == true? "Already Finalized": "Finalize" %>'
CssClass="" ToolTip="Finalize" CommandName="Finalize"
CommandArgument='<%#Eval("IsFinalized")%>' Enabled='<%# Convert.ToBoolean(Eval("IsFinalized")) == true? false: true %>'></asp:LinkButton>
<ajax:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" DisplayModalPopupID="mpe2" TargetControlID="btnFinalizedRecord">
</ajax:ConfirmButtonExtender>
<ajax:ModalPopupExtender ID="mpe2" runat="server" PopupControlID="pnlPopup2" TargetControlID="btnFinalizedRecord" OkControlID="btnYes"
CancelControlID="btnNo" BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
<asp:Panel ID="pnlPopup2" runat="server" CssClass="modalPopup" Style="display: none">
<div class="header">
Confirmation
</div>
<div class="body">
Are you sure to <b>Finalize</b>?
<asp:CheckBox ID="chkConfirmFinalize" runat="server" AutoPostBack="true" OnCheckedChanged="chkConfirmFinalize_CheckedChanged" />
<br />
You will not be able to perform an edit after finalizing.
</div>
<div class="Popupfooter" align="right">
<asp:Button ID="btnYes" Enabled="false" CssClass="btn btn-sm btn-danger" runat="server" Text="Yes" />
<asp:Button ID="btnNo" CssClass="btn btn-sm btn-primary" runat="server" Text="No" />
</div>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
.cs代码:
protected void chkConfirmFinalize_CheckedChanged(object sender, EventArgs e)
{
try
{
var chkConfirmFinalize = sender as CheckBox;
GridViewRow gr = (GridViewRow)chkConfirmFinalize.NamingContainer;
Panel pnlPopup2 = gr.FindControl("pnlPopup2") as Panel;
if (chkConfirmFinalize.Checked == true)
{
btnYes.Visible = true;
}
else
{
btnYes.Visible = false;
}
pnlPopup2.Visible = true;
}
catch (Exception ex)
{
Utility.Msg_Error(Master, ex.Message);
}
}