我的主程序窗口是一个弹出窗口页面,
程序中Excel的导出是通过DataSet数据集导出的,在导出Excel程序中并不存在关闭窗口的语句,
但是只要点击导出Excel按钮,不论选“打开”“保存”“取消”主程序窗口都回被关闭?选“保存”还好,窗口关闭后还可以将导出数据保存,但是“打开”“取消”按钮点击后的效果就是主程序窗口被关闭,什么操作也没有。
以上的现象是在我使用了Page_Unload()事件后出现的,但是我将所有Page_Unoad()事件注释掉后,这个现象还存在。
具体不知问题出在哪里,还请高手指点

解决方案 »

  1.   

    code??
    page_load 部分
    和aspx的form部分
      

  2.   

    以下:Page_Load
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(!Page.IsPostBack)
    {
    //初始化填充DataSet,此中数据会驻留内存,直到使用它的程序源结束
    dSet = PublicClass.ObjSQL.ReturnDataSet(BindSQL,PublicClass.ObjSQL.SQLConn);
    //调用排序函数,并传递页面初始化排序参数
    Sort(ViewState["StrSort"]);
    //初始化牌号名称查询下拉框
    PublicClass.ObjControl.DropdownListBindSearch(SerBrandName,PublicClass.ObjSQL.SQLConn,"sc001","sc0101","sc0102","sc0102");
    }
    }以下:aspx的form部分
    <form id="Form1" method="post" runat="server">
    <!--显示标题--><uc1:banner2 id="Banner2" runat="server"></uc1:banner2>
    <!--结束显示标题-->
    <TABLE height="26" cellSpacing="0" cellPadding="0" width="100%" align="center" bgColor="#2175de"
    border="0">
    <TR>
    <TD style="BORDER-BOTTOM: black 1px solid" noWrap align="left" width="30%" colSpan="1"
    height="25" rowSpan="1"><FONT face="宋体">&nbsp;</FONT></TD>
    <TD style="BORDER-BOTTOM: black 1px solid" noWrap align="center" width="40%"></B><asp:label id="PageTitle" runat="server" ForeColor="White" Font-Bold="True"></asp:label></TD>
    <TD style="BORDER-BOTTOM: black 1px solid" noWrap align="right" width="30%" colSpan="1"
    rowSpan="1"><asp:button id="Add" Visible="False" CssClass="btn" Width="40px" Height="19px" Runat="server"
    Text="新增"></asp:button><FONT face="宋体">&nbsp;</FONT>
    </TD>
    </TR>
    <TR>
    <TD style="BORDER-BOTTOM: black 1px solid" noWrap align="left" width="30%" colSpan="3"
    height="25" rowSpan="1"><FONT face="宋体">&nbsp;</FONT>
    <asp:label id="PageInfo" runat="server" ForeColor="White" Font-Bold="True"></asp:label>&nbsp;<FONT face="宋体">
    </FONT>
    <asp:label id="YP" runat="server" Font-Bold="True" ForeColor="White"></asp:label></TD>
    </TR>
    <TR>
    <TD style="BORDER-BOTTOM: black 1px solid" noWrap align="left" width="30%" colSpan="3"
    height="25"><FONT face="宋体">&nbsp;
    <asp:label id="Label2" runat="server" ForeColor="White" Font-Bold="True">牌号名称:</asp:label><asp:dropdownlist id="SerBrandName" runat="server" Width="140px" AutoPostBack="True"></asp:dropdownlist>&nbsp;
    <asp:label id="Label1" runat="server" ForeColor="White" Font-Bold="True">班别:</asp:label><asp:dropdownlist id="SerClass" runat="server" Width="60px" AutoPostBack="True">
    <asp:ListItem></asp:ListItem>
    <asp:ListItem Value="甲班">甲班</asp:ListItem>
    <asp:ListItem Value="乙班">乙班</asp:ListItem>
    <asp:ListItem Value="丙班">丙班</asp:ListItem>
    <asp:ListItem Value="丁班">丁班</asp:ListItem>
    </asp:dropdownlist>&nbsp;
    <asp:label id="Label3" runat="server" ForeColor="White" Font-Bold="True">开始日期:</asp:label><asp:textbox id="SerStartDate" runat="server" CssClass="liuyan" Width="80px" ToolTip="格式: 2001-01-01"></asp:textbox><INPUT class="btn" style="WIDTH: 22px; HEIGHT: 18px" onclick="OpenDate(SerStartDate)" type="button"
    value="日">&nbsp;
    <asp:label id="Label4" runat="server" ForeColor="White" Font-Bold="True">结束日期:</asp:label><asp:textbox id="SerEndDate" runat="server" CssClass="liuyan" Width="80px" ToolTip="格式: 2001-01-01"></asp:textbox><INPUT class="btn" style="WIDTH: 22px; HEIGHT: 18px" onclick="OpenDate(SerEndDate)" type="button"
    value="日">&nbsp;
    <asp:button id="SearchButton" CssClass="btn" Width="40px" Height="19px" Runat="server" Text="查询"></asp:button>&nbsp;
    <asp:button id="ExcelExport" Text="Excel" Runat="server" Height="19px" Width="40px" CssClass="btn"></asp:button></FONT></TD>
    </TR>
    </TABLE>
    <asp:datagrid id="QP_DataGrid" runat="server" Width="100%" AllowSorting="True" AllowPaging="True"
    PageSize="23" Font-Size="9pt" CellSpacing="1" HeaderStyle-VerticalAlign="Middle" AutoGenerateColumns="False"
    BorderColor="#9DA9B6" BorderWidth="1px">
    <SelectedItemStyle BackColor="#9999FF"></SelectedItemStyle>
    <ItemStyle HorizontalAlign="Center" Height="20px" VerticalAlign="Middle"></ItemStyle>
    <HeaderStyle HorizontalAlign="Center" Height="25px" ForeColor="White" BorderColor="#9DA9B6" VerticalAlign="Middle"
    BackColor="#1A6AAF"></HeaderStyle>
    <Columns>
    <asp:ButtonColumn Text="选择" DataTextField="Sc0402" SortExpression="Sc0402" HeaderText="开始时间" CommandName="Select">
    <HeaderStyle Width="15%"></HeaderStyle>
    </asp:ButtonColumn>
    <asp:BoundColumn Visible="False" DataField="Sc0402" SortExpression="Sc0402" HeaderText="开始时间">
    <ItemStyle Wrap="False" Width="15%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0403" SortExpression="Sc0403" HeaderText="结束时间">
    <ItemStyle Wrap="False" Width="15%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0497" SortExpression="Sc0497" HeaderText="班别">
    <ItemStyle Wrap="False" Width="7%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Brand_Name" SortExpression="Brand_Name" HeaderText="牌号名称">
    <ItemStyle Wrap="False" Width="10%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0503" SortExpression="Sc0503" HeaderText="叶片重量" DataFormatString="{0:0}">
    <ItemStyle Wrap="False" Width="8%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0401" SortExpression="Sc0401" HeaderText="调度指令">
    <ItemStyle Wrap="False" Width="10%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0407" SortExpression="Sc0407" HeaderText="批次">
    <ItemStyle Wrap="False" Width="7%"></ItemStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="Sc0498" SortExpression="Sc0498" HeaderText="生产日期">
    <ItemStyle Wrap="False" Width="13%"></ItemStyle>
    </asp:BoundColumn>
    <asp:TemplateColumn HeaderText="操  作">
    <ItemStyle Width="15%"></ItemStyle>
    <ItemTemplate>
    <asp:LinkButton id="Detail" runat="server" CommandName="Detail" ToolTip="查看并编辑记录">详细</asp:LinkButton>&nbsp;
    <asp:LinkButton id="Delete" runat="server" CommandName="Delete" ToolTip="删除纪录">删除</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle Visible="False"></PagerStyle>
    </asp:datagrid>
    <TABLE id="Table1" borderColor="#9da9b6" cellSpacing="0" cellPadding="0" width="100%" align="center"
    border="1">
    <TR align="center" height="25">
    <TD align="center"><asp:linkbutton id="First" Runat="server" Text="首页" CommandName="First"></asp:linkbutton>&nbsp;
    <asp:linkbutton id="Previous" Runat="server" Text="上一页" CommandName="Previous" Enabled="False"></asp:linkbutton>&nbsp;&nbsp;&nbsp;
    <asp:label id="CurrentPage" runat="server" ForeColor="Gray"></asp:label>&nbsp;&nbsp; 
    &nbsp;
    <asp:linkbutton id="Next" Runat="server" Text="下一页" CommandName="Next"></asp:linkbutton>&nbsp;
    <asp:linkbutton id="Last" Runat="server" Text="尾页" CommandName="Last"></asp:linkbutton></TD>
    </TR>
    </TABLE>
    </form>
      

  3.   

    这个问题应该不是代码的问题,这些程序我都没动过,以前运行好好的,但就在我改了其他地方以后就有问题了,导出Excel的程序都没有改过