Gridview 未显示在与 ModalPopupExtender 关联的面板中

发布于 2024-10-29 21:00:11 字数 6659 浏览 0 评论 0原文

我有两个与 modalpopupextender 关联的图像按钮。当我单击 imagebutton1 时,它会打开面板,并且在该面板内有一个加载信息的网格。但是,当我单击 Imagebutton2 时,它会打开面板,但不会显示 gridview,即使该 gridview 标签位于该面板下方。

我对网络很陌生,请帮忙。谢谢。请找到下面的代码:

<asp:Panel ID="PNL" ScrollBars="Auto" runat="server" Style="border: 2px solid Black; display: none; width: auto;
        background-color: White; padding: 20px; text-align: center;" Height="444">
        <asp:Label ID="LabelCount" runat="server" Text="Label" Font-Size="Large" 
            style="text-align: center"></asp:Label>
        <asp:Button ID="ButtonOK" Text="OK" runat="server" />
        <%-- Area for keeping POPUP grid ot window or picture DO NOT PUT UNDER TABLE Taj 3-Jan-2010--%>                

            <asp:GridView ID="gvUsersWHYME" runat="server" BackColor="White" BorderColor="#010101"
            BorderStyle="None" CaptionAlign="Top" CellPadding="1" CellSpacing="2" GridLines="None"
            Style="margin-left: 0px" DataSourceID="SqlDataSource0" AutoGenerateColumns="False"
            EnableTheming="False" AllowSorting="True" 
            OnRowDataBound="gvUsers_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Roles" Visible="False">
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkAll" runat="server" 
                            onclick="javascript:SelectAllCheckboxesSpecific(this);" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkGenerate" runat="server" 
                            onclick="javascript:HighlightRow(this);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ProjectNum" HeaderText="Release#" SortExpression="ProjectNum"
                    ReadOnly="true" />
                    <asp:BoundField DataField="IPMRefNum" HeaderText="IPM Ref #" 
                    SortExpression="IPMRefNum" />
                <asp:BoundField DataField="TestprojectNo" HeaderText="Release Description" SortExpression="TestprojectNo"
                    ItemStyle-Width="444">
                    <ItemStyle Width="444px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="ProjectName" HeaderText="ProjectName" SortExpression="ProjectName"
                    Visible="False" />

                <asp:BoundField DataField="ProposedPhaseName" HeaderText="Proposed Phase Name" ItemStyle-Wrap="False"
                    SortExpression="ProposedPhaseName">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="DependencyList" HeaderText="Dependency List" 
                    SortExpression="DependencyList" />
                <asp:BoundField DataField="QA_Planned_EndDate" HeaderText="Release Handover Date"
                    SortExpression="QA_Planned_EndDate" DataFormatString="{0:d}" 
                    ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Applications" HeaderText="Impacted Application(s)" 
                    SortExpression="Applications" />
                <asp:BoundField DataField="AppCount" HeaderText="Count" 
                    SortExpression="AppCount" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#330099" />
            <RowStyle BackColor="White" ForeColor="#330099" />
            <HeaderStyle BackColor="#ACCDF6" Font-Bold="True" ForeColor="#FFFFCC" />
        </asp:GridView>
        <asp:Label  ID="lblCountImpacted" runat="server" Text="Total Impacted App."  
            Font-Size="Large"></asp:Label>            
    </asp:Panel>
    <br />
    <br />
    <br />
    <br />
    <br />
     <asp:Panel ID="Panel1" ScrollBars="Auto" runat="server" Style="border: 2px solid Black; display: none; width: auto;
        background-color: White; padding: 20px; text-align: center;" Height="444">
        <asp:Button ID="Button1" Text="OK" runat="server" />
     <asp:GridView ID="GridView4" runat="server" BackColor="White" BorderColor="#010101"
            BorderStyle="None" CaptionAlign="Top" CellPadding="1" CellSpacing="2" GridLines="None"
            Style="margin-left: 0px" DataSourceID="SqlDataSource6" AutoGenerateColumns="False"
            EnableTheming="False" AllowSorting="True" 
            OnRowDataBound="GridView4_RowDataBound">
            <Columns>                
                <asp:BoundField DataField="ProjectNum" HeaderText="Release#" SortExpression="ProjectNum"
                    ReadOnly="true" />
                    <asp:BoundField DataField="IPMRefNum" HeaderText="IPM Ref #" 
                    SortExpression="IPMRefNum" />
                <asp:BoundField DataField="TestprojectNo" HeaderText="Release Description" SortExpression="TestprojectNo"
                    ItemStyle-Width="444">
                    <ItemStyle Width="444px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="ProjectName" HeaderText="ProjectName" SortExpression="ProjectName"
                    Visible="False" />

                <asp:BoundField DataField="ProposedPhaseName" HeaderText="Proposed Phase Name" ItemStyle-Wrap="False"
                    SortExpression="ProposedPhaseName">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="DependencyList" HeaderText="Dependency List" 
                    SortExpression="DependencyList" />
                <asp:BoundField DataField="QA_Planned_EndDate" HeaderText="Release Handover Date"
                    SortExpression="QA_Planned_EndDate" DataFormatString="{0:d}" 
                    ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#330099" />
            <RowStyle BackColor="White" ForeColor="#330099" />
            <HeaderStyle BackColor="#ACCDF6" Font-Bold="True" ForeColor="#FFFFCC" />
        </asp:GridView>
     </asp:Panel>

I have two imagebuttons which are associated with a modalpopupextender. When I click imagebutton1, it opens up the panel and within that panel there is a grid which loads with the information. However, when I click Imagebutton2 it opens up the panel but does not display the gridview even though that gridview tag is under that panel.

I am pretty new with web, please help. Thank You. Please find the code below:

<asp:Panel ID="PNL" ScrollBars="Auto" runat="server" Style="border: 2px solid Black; display: none; width: auto;
        background-color: White; padding: 20px; text-align: center;" Height="444">
        <asp:Label ID="LabelCount" runat="server" Text="Label" Font-Size="Large" 
            style="text-align: center"></asp:Label>
        <asp:Button ID="ButtonOK" Text="OK" runat="server" />
        <%-- Area for keeping POPUP grid ot window or picture DO NOT PUT UNDER TABLE Taj 3-Jan-2010--%>                

            <asp:GridView ID="gvUsersWHYME" runat="server" BackColor="White" BorderColor="#010101"
            BorderStyle="None" CaptionAlign="Top" CellPadding="1" CellSpacing="2" GridLines="None"
            Style="margin-left: 0px" DataSourceID="SqlDataSource0" AutoGenerateColumns="False"
            EnableTheming="False" AllowSorting="True" 
            OnRowDataBound="gvUsers_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Roles" Visible="False">
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkAll" runat="server" 
                            onclick="javascript:SelectAllCheckboxesSpecific(this);" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkGenerate" runat="server" 
                            onclick="javascript:HighlightRow(this);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ProjectNum" HeaderText="Release#" SortExpression="ProjectNum"
                    ReadOnly="true" />
                    <asp:BoundField DataField="IPMRefNum" HeaderText="IPM Ref #" 
                    SortExpression="IPMRefNum" />
                <asp:BoundField DataField="TestprojectNo" HeaderText="Release Description" SortExpression="TestprojectNo"
                    ItemStyle-Width="444">
                    <ItemStyle Width="444px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="ProjectName" HeaderText="ProjectName" SortExpression="ProjectName"
                    Visible="False" />

                <asp:BoundField DataField="ProposedPhaseName" HeaderText="Proposed Phase Name" ItemStyle-Wrap="False"
                    SortExpression="ProposedPhaseName">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="DependencyList" HeaderText="Dependency List" 
                    SortExpression="DependencyList" />
                <asp:BoundField DataField="QA_Planned_EndDate" HeaderText="Release Handover Date"
                    SortExpression="QA_Planned_EndDate" DataFormatString="{0:d}" 
                    ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Applications" HeaderText="Impacted Application(s)" 
                    SortExpression="Applications" />
                <asp:BoundField DataField="AppCount" HeaderText="Count" 
                    SortExpression="AppCount" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#330099" />
            <RowStyle BackColor="White" ForeColor="#330099" />
            <HeaderStyle BackColor="#ACCDF6" Font-Bold="True" ForeColor="#FFFFCC" />
        </asp:GridView>
        <asp:Label  ID="lblCountImpacted" runat="server" Text="Total Impacted App."  
            Font-Size="Large"></asp:Label>            
    </asp:Panel>
    <br />
    <br />
    <br />
    <br />
    <br />
     <asp:Panel ID="Panel1" ScrollBars="Auto" runat="server" Style="border: 2px solid Black; display: none; width: auto;
        background-color: White; padding: 20px; text-align: center;" Height="444">
        <asp:Button ID="Button1" Text="OK" runat="server" />
     <asp:GridView ID="GridView4" runat="server" BackColor="White" BorderColor="#010101"
            BorderStyle="None" CaptionAlign="Top" CellPadding="1" CellSpacing="2" GridLines="None"
            Style="margin-left: 0px" DataSourceID="SqlDataSource6" AutoGenerateColumns="False"
            EnableTheming="False" AllowSorting="True" 
            OnRowDataBound="GridView4_RowDataBound">
            <Columns>                
                <asp:BoundField DataField="ProjectNum" HeaderText="Release#" SortExpression="ProjectNum"
                    ReadOnly="true" />
                    <asp:BoundField DataField="IPMRefNum" HeaderText="IPM Ref #" 
                    SortExpression="IPMRefNum" />
                <asp:BoundField DataField="TestprojectNo" HeaderText="Release Description" SortExpression="TestprojectNo"
                    ItemStyle-Width="444">
                    <ItemStyle Width="444px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="ProjectName" HeaderText="ProjectName" SortExpression="ProjectName"
                    Visible="False" />

                <asp:BoundField DataField="ProposedPhaseName" HeaderText="Proposed Phase Name" ItemStyle-Wrap="False"
                    SortExpression="ProposedPhaseName">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="DependencyList" HeaderText="Dependency List" 
                    SortExpression="DependencyList" />
                <asp:BoundField DataField="QA_Planned_EndDate" HeaderText="Release Handover Date"
                    SortExpression="QA_Planned_EndDate" DataFormatString="{0:d}" 
                    ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False"></ItemStyle>
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#330099" />
            <RowStyle BackColor="White" ForeColor="#330099" />
            <HeaderStyle BackColor="#ACCDF6" Font-Bold="True" ForeColor="#FFFFCC" />
        </asp:GridView>
     </asp:Panel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-11-05 21:00:11

我创建了一个示例代码。与您的问题类似。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MasterDetail.aspx.cs"
Inherits="MasterDetail" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Untitled Page</title>
</head>
<body>
   <form id="form" runat="server">
       <asp:ScriptManager ID="scriptManager" runat="server" />
       <div>
           <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
               <ContentTemplate>
                   <asp:Label ID="lblTitle" runat="server" Text="Customers" BackColor="lightblue" Width="95%" />
                   <asp:GridView ID="gvCustomers" runat="server" DataKeyNames="Id" AutoGenerateColumns="false"
                       AllowPaging="true" AllowSorting="true" PageSize="10" Width="95%">
                       <AlternatingRowStyle BackColor="aliceBlue" />
                       <HeaderStyle HorizontalAlign="Left" />
                       <Columns>
                           <asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px">
                               <ItemTemplate>
                                   <asp:Button ID="btnViewDetails" runat="server" Text="Details" OnClick="BtnViewDetails_Click" />
                               </ItemTemplate>
                           </asp:TemplateField>
                           <asp:BoundField DataField="Id" HeaderText="ID" SortExpression="Id" ReadOnly="true" />
                           <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="contactname" ReadOnly="true" />
                       </Columns>
                   </asp:GridView>
               </ContentTemplate>
           </asp:UpdatePanel>
           <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
           <ajaxtoolkit:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
               PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
           <asp:Panel ID="pnlPopup" runat="server" Width="500px" Style="display: none">
               <asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
                   <ContentTemplate>
                       <asp:Label ID="lblCustomerDetail" runat="server" Text="Customer Detail" BackColor="lightblue"
                           Width="95%" />
                       <asp:DetailsView ID="dvCustomerDetail" runat="server" DefaultMode="Edit" Width="95%"
                           BackColor="white" />
                   </ContentTemplate>
               </asp:UpdatePanel>
               <div align="right" style="width: 95%">
                   <asp:Button ID="btnSave" runat="server" Text="Save"
OnClientClick="alert('Sorry, but I didnt implement save '); return false;"
                       Width="50px" />
                   <asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" />
               </div>
           </asp:Panel>
       </div>
   </form>
</body>
</html>



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterDetail : System.Web.UI.Page
{
    DataSet ds;
    protected void Page_Load(object sender, EventArgs e)
    {

        ds = Data();
        if (!this.IsPostBack)
        {
            if (Session["parent"] == null)
            {
                gvCustomers.DataSource = ds.Tables["Parent"];
                gvCustomers.DataBind();
            }
            else
            {
                gvCustomers.DataSource = Session["Parent"] as DataTable;
                gvCustomers.DataBind();

            }
        }

    }
    private DataSet Data()
    {

        DataTable dt = new DataTable();
        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Name", typeof(string));

        dt.Rows.Add(new object[] { 1, "aaaa" });
        dt.Rows.Add(new object[] { 2, "bbbb" });
        dt.Rows.Add(new object[] { 3, "cccc" });
        dt.TableName = "Parent";




        DataTable dtc = new DataTable();
        dtc.Columns.Add("Id", typeof(int));
        dtc.Columns.Add("Qul", typeof(string));

        dtc.Rows.Add(new object[] { 1, "aaaa" });
        dtc.Rows.Add(new object[] { 2, "bbbb" });
        dtc.Rows.Add(new object[] { 3, "bbbb" });
        dtc.TableName = "Child";


        DataSet ds = new DataSet();

        ds.Tables.Add(dt);
        ds.Tables.Add(dtc);
        Session["Parent"] = dt;

        return ds;

    }
    protected void BtnViewDetails_Click(object sender, EventArgs e)
    {
        //  get the gridviewrow from the sender so we can get the datakey we need
        Button btnDetails = sender as Button;
        GridViewRow row = (GridViewRow)btnDetails.NamingContainer;

        //  extract the id from the row whose details button originated the postback.
        //  grab the customerid and feed it to the customer details datasource
        //  finally, rebind the detailview
        DataView dv = new DataView(ds.Tables["Child"]);

        dv.RowFilter = "Id=" + Convert.ToString(this.gvCustomers.DataKeys[row.RowIndex].Value);
        dvCustomerDetail.DataSource = dv;
        dvCustomerDetail.DataBind();

        //  update the contents in the detail panel
        this.updPnlCustomerDetail.Update();
        //  show the modal popup
        this.mdlPopup.Show();
    }  
}

I have created a sample code.Similar to your problem.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MasterDetail.aspx.cs"
Inherits="MasterDetail" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Untitled Page</title>
</head>
<body>
   <form id="form" runat="server">
       <asp:ScriptManager ID="scriptManager" runat="server" />
       <div>
           <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
               <ContentTemplate>
                   <asp:Label ID="lblTitle" runat="server" Text="Customers" BackColor="lightblue" Width="95%" />
                   <asp:GridView ID="gvCustomers" runat="server" DataKeyNames="Id" AutoGenerateColumns="false"
                       AllowPaging="true" AllowSorting="true" PageSize="10" Width="95%">
                       <AlternatingRowStyle BackColor="aliceBlue" />
                       <HeaderStyle HorizontalAlign="Left" />
                       <Columns>
                           <asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px">
                               <ItemTemplate>
                                   <asp:Button ID="btnViewDetails" runat="server" Text="Details" OnClick="BtnViewDetails_Click" />
                               </ItemTemplate>
                           </asp:TemplateField>
                           <asp:BoundField DataField="Id" HeaderText="ID" SortExpression="Id" ReadOnly="true" />
                           <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="contactname" ReadOnly="true" />
                       </Columns>
                   </asp:GridView>
               </ContentTemplate>
           </asp:UpdatePanel>
           <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
           <ajaxtoolkit:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
               PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
           <asp:Panel ID="pnlPopup" runat="server" Width="500px" Style="display: none">
               <asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
                   <ContentTemplate>
                       <asp:Label ID="lblCustomerDetail" runat="server" Text="Customer Detail" BackColor="lightblue"
                           Width="95%" />
                       <asp:DetailsView ID="dvCustomerDetail" runat="server" DefaultMode="Edit" Width="95%"
                           BackColor="white" />
                   </ContentTemplate>
               </asp:UpdatePanel>
               <div align="right" style="width: 95%">
                   <asp:Button ID="btnSave" runat="server" Text="Save"
OnClientClick="alert('Sorry, but I didnt implement save '); return false;"
                       Width="50px" />
                   <asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" />
               </div>
           </asp:Panel>
       </div>
   </form>
</body>
</html>



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterDetail : System.Web.UI.Page
{
    DataSet ds;
    protected void Page_Load(object sender, EventArgs e)
    {

        ds = Data();
        if (!this.IsPostBack)
        {
            if (Session["parent"] == null)
            {
                gvCustomers.DataSource = ds.Tables["Parent"];
                gvCustomers.DataBind();
            }
            else
            {
                gvCustomers.DataSource = Session["Parent"] as DataTable;
                gvCustomers.DataBind();

            }
        }

    }
    private DataSet Data()
    {

        DataTable dt = new DataTable();
        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Name", typeof(string));

        dt.Rows.Add(new object[] { 1, "aaaa" });
        dt.Rows.Add(new object[] { 2, "bbbb" });
        dt.Rows.Add(new object[] { 3, "cccc" });
        dt.TableName = "Parent";




        DataTable dtc = new DataTable();
        dtc.Columns.Add("Id", typeof(int));
        dtc.Columns.Add("Qul", typeof(string));

        dtc.Rows.Add(new object[] { 1, "aaaa" });
        dtc.Rows.Add(new object[] { 2, "bbbb" });
        dtc.Rows.Add(new object[] { 3, "bbbb" });
        dtc.TableName = "Child";


        DataSet ds = new DataSet();

        ds.Tables.Add(dt);
        ds.Tables.Add(dtc);
        Session["Parent"] = dt;

        return ds;

    }
    protected void BtnViewDetails_Click(object sender, EventArgs e)
    {
        //  get the gridviewrow from the sender so we can get the datakey we need
        Button btnDetails = sender as Button;
        GridViewRow row = (GridViewRow)btnDetails.NamingContainer;

        //  extract the id from the row whose details button originated the postback.
        //  grab the customerid and feed it to the customer details datasource
        //  finally, rebind the detailview
        DataView dv = new DataView(ds.Tables["Child"]);

        dv.RowFilter = "Id=" + Convert.ToString(this.gvCustomers.DataKeys[row.RowIndex].Value);
        dvCustomerDetail.DataSource = dv;
        dvCustomerDetail.DataBind();

        //  update the contents in the detail panel
        this.updPnlCustomerDetail.Update();
        //  show the modal popup
        this.mdlPopup.Show();
    }  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文