我有一个ajax模式弹出扩展器,我用它来显示带有一些数据的gridview。似乎ModalPopup在数据绑定到GridView之前弹出:
protected void grdrequisitionraisedbyme_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("viewhistory"))
{
GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
LinkButton lnkclaimno = (LinkButton)clickedRow.FindControl("lnkclaimno");
DataSet ds = new DataSet();
ds = GetHistory(lnkclaimno.Text.Trim());
grvcapexhistory.DataSource = null;
grvcapexhistory.DataBind();
if (ds.Tables[0].Rows.Count > 0)
{
grvcapexhistory.DataSource = ds.Tables[0];
grvcapexhistory.DataBind();
popup.Show();
}
}
}
我放置了一个调试器,其中grvcapexhistory
被绑定但弹出窗口已经弹出,即使断点没有达到popup.Show()
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnrefresh" />
<asp:AsyncPostBackTrigger ControlID="grdrequisitionraisedbyme" />
</Triggers>
<ContentTemplate>
<div style="height: 300px; overflow-y: scroll;">
<asp:GridView ID="grdrequisitionraisedbyme" runat="server" CssClass="tabledata" OnRowCommand="grdrequisitionraisedbyme_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Capex/Po No">
<ItemTemplate>
<asp:LinkButton ID="lnkclaimno" runat="server" ForeColor="#3366FF" Text='<%# Eval("CapexNo") %>'
CommandName="select"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View History">
<ItemTemplate>
<asp:LinkButton ID="lnkviewhistory" runat="server" CommandName="viewhistory" ForeColor="#3366FF"
Text="View History"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<br />
<br />
</div>
<asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup" Style="display: none">
<asp:Label Font-Bold="true" ID="Label4" runat="server" Text="Customer Details"></asp:Label>
<br />
<table align="center">
<tr>
<td colspan="6">
<asp:GridView ID="grvcapexhistory" runat="server" CssClass="tabledata">
</asp:GridView>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="return Hidepopup()" />
</td>
</tr>
</table>
</asp:Panel>
<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<asp:ModalPopupExtender ID="popup" runat="server" DropShadow="false" PopupControlID="pnlAddEdit"
TargetControlID="lnkFake" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
答案 0 :(得分:1)
摆脱Ajax弹出窗口并使用下面的内容。它会解决你的问题。
<asp:Panel ID="popup" runat="server" visible="false">
<table style="position: fixed; z-index: 1; left: 0px; top: 0px" border="0" width="100%" height="100%">
<tr>
<td valign="top" align="center" >
// below div will automatically expand as much as needed
<div class="yourmodalclass" style=" display:inline-block;margin-top:90px; ">
//put your GridView ID="grvcapexhistory" and other stuff here
</div>
</td>
</table>
</asp:Panel>
使用popup.Visible = true;
随时显示此弹出窗口 在弹出窗口中放一个按钮。 onclick = popup.Visible = false;此弹出窗口可让您完全控制所有回发问题。
你可以在这里看到这个:http://atldunia.com/youtube/Zpopup.aspx