我有一个gridview,它出现在动态生成的模态弹出窗口中,并绑定到动态生成的SqlDataSource。
我这样做是为了充分利用gridview的自动编辑功能。
我的问题是,当点击编辑按钮时,尽管我的gridview在更新面板中,但由于完整的回发,modalpopup关闭...
我查看了解决方案here和here,但都没有解决问题。我还尝试了关于ModalPopupExtender相对于更新面板等的定位的所有组合,并尝试将UpdateMode更改为条件。
标记:
<span class="none"><asp:Button ID="btnDummy" runat="server" Text="Dummy" /></span>
<ajax:ModalPopupExtender ID="mpLabel" runat="server" TargetControlID="btnDummy" BackgroundCssClass="modalBackground" PopupControlID="pnlLabels"></ajax:ModalPopupExtender>
<asp:Panel ID="pnlLabels" DefaultButton="btnOk" Style="display:none;" runat="server">
<div style="background-color:#fff;border:1px solid black;padding:7px;">
<asp:UpdatePanel ID="upLabels" runat="server" ChildrenAsTriggers="true" EnableViewState="true" UpdateMode="Always">
<ContentTemplate>
<asp:Panel ID="pnlGv" runat="server" style="max-height:420px;width:700px;border-bottom:1px #ccc solid;" ScrollBars="Vertical">
<asp:PlaceHolder ID="phLabelInfo" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="phSDS" runat="server"></asp:PlaceHolder>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnOk" runat="server" Text="Ok" />
</div>
</asp:Panel>
代码背后:
Dim sdsLabels As New SqlDataSource
sdsLabels.ID = "sdsLabels"
sdsLabels.ConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("Generic Connection String")
sdsLabels.ProviderName = "System.Data.SqlClient"
sdsLabels.DeleteCommand = "DELETE FROM [JS_LABELS] WHERE [LABELID] = @LabelId"
sdsLabels.SelectCommand = "SELECT [LABELID], [CIRCUITNUMBER], [PANELNUMBER], [ADDITIONAL1], [ADDITIONAL2], [ADDITIONAL3] FROM [JS_LABELS] WHERE [QUOTEITEMID] = @QuoteItemId"
sdsLabels.UpdateCommand = "UPDATE [JS_LABELS] SET [CIRCUITNUMBER] = @CircuitNumber, [PANELNUMBER] = @PanelNumber, [ADDITIONAL1] = @Additional1, [ADDITIONAL2] = @Additional2, [ADDITIONAL3] = @Additional3 WHERE [LABELID] = @LABELID"
sdsLabels.SelectParameters.Add(New Parameter("QuoteItemId", Data.DbType.Int32, e.CommandArgument.ToString()))
sdsLabels.DeleteParameters.Add(New Parameter("LabelId", Data.DbType.Int32))
Dim paramCollection As New ParameterCollection
paramCollection.Add("CircuitNumber", Data.DbType.String, "")
paramCollection.Add("PanelNumber", Data.DbType.String, "")
paramCollection.Add("Additional1", Data.DbType.String, "")
paramCollection.Add("Additional2", Data.DbType.String, "")
paramCollection.Add("Additional3", Data.DbType.String, "")
paramCollection.Add("LabelId", Data.DbType.Int32, "0")
Dim ph As New PlaceHolder
ph = CType(PageHelper.RecursiveFindControl(Page, "phSDS"), PlaceHolder)
ph.Controls.Add(sdsLabels)
Dim gv As New GridView
ph = CType(PageHelper.RecursiveFindControl(Page, "phLabelInfo"), PlaceHolder)
ph.Controls.Add(gv)
gv.CssClass = "LabelsTable"
Dim LabelId() As String = {"LabelId"}
gv.DataKeyNames = LabelId
gv.EnableViewState = True
gv.AutoGenerateEditButton = True
AddHandler gv.RowCommand, AddressOf gv_rowCommand
gv.DataSourceID = sdsLabels.ID
gv.DataBind()
mpLabel.Show()
答案 0 :(得分:0)
根据我的经验,ModalPopupExtender将始终关闭回发,除非你明确要求它不会在回发触发的事件中:
btnSubmitRequest_ModalPopupExtender.Show();