ASP.net:如何在ajax modalpopupextender中显示gridview

时间:2011-04-21 06:51:19

标签: c# asp.net asp.net-ajax

我不知道如何让它工作......我正在使用带有C#的ASP.net而我正在设计一个搜索用户控件

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel runat="server">
  <ContentTemplate>
    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
    TargetControlID="btnFind" CancelControlID="btnCancel" PopupControlID="Panel" 
    PopupDragHandleControlID="Panel" BackgroundCssClass="modalBackground" </asp:ModalPopupExtender>
    <asp:Panel ID="Panel" runat="server" CssClass="ModalWindow">


    <asp:GridView ID="grdInfo" runat="server" >
        <Columns>
            <asp:TemplateField HeaderText="Select">
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" CommandName="Select" Text="Button" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

   <br />
       <asp:Button ID="btnCancel" runat="server" Text="Cancel" />

    </asp:Panel>
  </ContentTemplate>
 </asp:UpdatePanel>

2 个答案:

答案 0 :(得分:3)

我有一个类似的ModalPopup,即使使用异步回发也可以像魅力一样工作。它是UserControl的一部分,因此我只显示相关部分(简化)+你的GridView。如果你说过你有什么问题,那会有所帮助。你把Grid绑定到DataSource的哪里?

<asp:ModalPopupExtender ID="ChargeFilterModalDialogExtender" runat="server" TargetControlID="BtnShowDialog" CancelControlID="BtnCloseChargeFilterControl" Drag="false" PopupControlID="Dialog_ChargeFilter" Enabled="True"   BackgroundCssClass="modalBackground" />
<asp:Button ID="BtnShowDialog" Style="display: none" runat="server" Width="120" Text="Filter Charges" ToolTip="show Chargefilter-Dialog" />
<asp:Panel id="Dialog_ChargeFilter" CssClass="modalPopup" runat="server" >
    <asp:Panel ID="DialogHeaderFrame"  CssClass="DialogHeaderFrame" runat="server">      
        <asp:Panel ID="DialogHeader"  runat="server" CssClass="DialogHeader" >
           &nbsp;<asp:Label ID="LblPopupHeader" runat="server" Text="Charge-Filter">
        </asp:Panel>
    </asp:Panel>  
    <asp:UpdatePanel ID="UpdGrdCharge" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false"  >
        <ContentTemplate>
            <asp:Button ClientIDMode="Static" ID="BtnCloseChargeFilterControl" Text="close filter" ToolTip="close filter-dialog" CausesValidation="false" Width="150px" runat="server" /><br />
            <asp:GridView ID="grdInfo" runat="server" >
                <Columns>
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:Button ID="Button1" runat="server" CommandName="Select" Text="Button" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </ContentTemplate> 
     </asp:UpdatePanel> 
</asp:Panel>

这是我的CSS(应该是无关紧要的,仅为了完整性):

.modalBackground
{
    background-color:silver;
    filter: alpha(opacity=60);
    opacity: 0.6;      
}

.modalPopup
{
    background-color:White;
    border: 1px solid #4C3C1B;
    padding: 5px;
}

.DialogHeader
{
    background-color:#002D64;  
    color:White;
    height:30px; 
    font-size:medium;
    font-style:normal;
    font-weight:bold;
    vertical-align:middle;
    display: table-cell;
}

.DialogHeaderFrame
{
    width:100%;
    cursor:default;
    background-color:white;  
    display:table;
}

答案 1 :(得分:0)

你们有必要手动更新你的面板吗?这是我能让我工作的唯一方法。基本上当我点击图像按钮时,我必须取消隐藏弹出窗口

gridview.databind()
updatepanel.update()
popup.show()

我做错了什么?