父窗题ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddChance.aspx.cs" Inherits="BaseOperation_AddChance"%>
<%@ Register Assembly="Microsoft.Web.UI.WebControls" Namespace="Microsoft.Web.UI.WebControls"
    TagPrefix="iewc" %>
<%@ Register Assembly="WebPager" Namespace="Hooyee.WebControls" TagPrefix="cc1" %>
<%@ Register Assembly="ZoneSoft.Web.UI" Namespace="ZoneSoft.Web.UI" TagPrefix="ZoneSoft" %>

<html>
<head runat="server">
    <title>添加渠道信息</title>
    <link href="../css/CRM.css" type="text/css" rel="stylesheet" />
    <script language="javascript" src="../css/Calendar.js"></script>
     <script language="javascript">

    function viewCustomer_onclick()
    {
        if ((document.all["listCompany"].value != '') && (document.all["listCompany"].value != '0'))
        {
            window.open('AddCustomer.aspx?id=' + document.all["listCompany"].value ,'','height=550,width=700,top=100,left=100,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes');
        }
    }

    function viewContact_onclick()
    {
        if ((document.all["listContact"].value != '') && (document.all["listContact"].value != '0'))
        {
            window.open('AddContact.aspx?id=' + document.all["listContact"].value ,'','height=500,width=700,top=100,left=100,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes');
        }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <iewc:Toolbar ID="topToolBar" runat="server" DefaultStyle="background-repeat:repeat;border:0;background-image:url(../images/menu/silver.gif);"
                                            Height="28px" OnButtonClick="Toolbar_ButtonClick" Style="border-right: #466094 1px solid;
                                            border-top: #466094 1px solid; font-size: 12px; border-left: #466094 1px solid;
                                            width: 100%; border-bottom: #466094 1px; font-family: 宋体">
            <iewc:ToolbarButton ID="chanceInfo" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/ico_18_service.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="渠道信息" />
            <iewc:ToolbarSeparator />
            <iewc:ToolbarButton ID="chanceListInfo" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/ico_16_changestatus.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="渠道明细" />
            <iewc:ToolbarSeparator />
            <iewc:ToolbarLabel DefaultStyle="background-image:url(../images/menu/silver.gif);width:100%;" />
        </iewc:Toolbar>
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
     
            <asp:View ID="vChanceListInfo" runat="server">
                <table style="width: auto; height: 100%">
                    <tr>
                        <td colspan="3" style="font-weight: bold; font-size: 20px; color: white; font-family: 楷体_GB2312;
                            height: 27px; background-color: #63769b">
                            渠道明细</td>
                    </tr>
                    <tr>
                        <td colspan="3" style="height: 277px">
                            <table style="left: 10px; width: 100%; height: 100%">
                                <tr>
                                    <td style="width: 928px; height: 24px">
                                        <iewc:Toolbar ID="Toolbar2" runat="server" DefaultStyle="background-repeat:repeat;border:0;background-image:url(../images/menu/silver.gif);"
                                            Height="28px" OnButtonClick="Toolbar_ButtonClick" Style="border-right: #466094 1px solid;
                                            border-top: #466094 1px solid; font-size: 12px; border-left: #466094 1px solid;
                                            width: 100%; border-bottom: #466094 1px; font-family: 宋体">
                                            <iewc:ToolbarButton ID="newChanceList" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/18_addResources.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="新建渠道明细" />
                                            <iewc:ToolbarSeparator />
                                        <iewc:ToolbarButton Text="导出到Excel" ImageUrl="../Images/ico/16_excel.gif" DefaultStyle="background-image:url(../images/menu/silver.gif);"
        ID="ChanceExcel" HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
        SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"></iewc:ToolbarButton>
       <iewc:ToolbarSeparator></iewc:ToolbarSeparator>
                                            <iewc:ToolbarLabel DefaultStyle="background-image:url(../images/menu/silver.gif);width:100%;" />
                                        </iewc:Toolbar>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="border-right: #ff9966 1px solid; border-top: #ff9966 1px solid;
                                        border-left: #ff9966 1px solid; width: 928px; border-bottom: #ff9966 1px solid;
                                        height: 371px" valign="top">
                                        <asp:GridView ID="GridView1" runat="server" AllowPaging="false" AutoGenerateColumns="False"
                                            CellPadding="4" CssClass="Grid" DataKeyNames="CHANCEDETAILID" EnableTheming="False"
                                            ForeColor="#333333" GridLines="None" OnRowCreated="GridView1_RowCreated" OnRowDeleting="GridView1_RowDeleting"
                                            PageSize="15" Style="word-break: keep-all" Width="100%">
                                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                            <Columns>
                                                <asp:HyperLinkField DataNavigateUrlFields="PRODUCTID" DataNavigateUrlFormatString="AddProduct.aspx?id={0}"
                                                    DataTextField="PRODUCTNAME" HeaderText="产品名称" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:HyperLinkField>
                                                <asp:BoundField DataField="AMOUNT" HeaderText="数量" ItemStyle-HorizontalAlign=Center>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="AGIO" HeaderText="折扣" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="MONEYSUM" HeaderText="总金额" DataFormatString="{0:N}" HtmlEncode="False" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:CommandField CausesValidation="False" HeaderText="删除" InsertVisible="False" ItemStyle-HorizontalAlign=Center
                                                    ShowCancelButton="False" ShowDeleteButton="True" />
                                            </Columns>
                                            <RowStyle BackColor="#EFF3FB" />
                                            <EditRowStyle BackColor="#2461BF" />
                                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                            <AlternatingRowStyle BackColor="White" />
                                            <PagerSettings Visible="False" />
                                            <EmptyDataTemplate>
                                                <font color="Navy">暂时无数据内容。</font>
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </asp:View>
       
        </asp:MultiView>
    </form>
</body>
</html>


父窗提.CS
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;
using System.Text;
using System.Data.SqlClient;
using Microsoft.Web.UI.WebControls;

public partial class BaseOperation_AddChance : System.Web.UI.Page
{
    private static string strSqlQuery;//存储查询串,带格式的,可配置参
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Request.QueryString["id"] != null)
            && (!string.IsNullOrEmpty(Request.QueryString["id"].Trim())))
        {
            this.sTitle.Text = this.Title = "查看/修改渠道信息";
        }

        if (!IsPostBack)
        {
            if (JS.isCookiesAvailabile())
            {
                if ((null == Request.QueryString["type"])
                    || (string.IsNullOrEmpty(Request.QueryString["type"].Trim())))
                {
                    JS.Alert("缺少类型字段。");
                    return;
                }

            

                if ((Request.QueryString["id"] != null)
                    && (!string.IsNullOrEmpty(Request.QueryString["id"].Trim()))
                    && initChanceInfo(Request.QueryString["id"].Trim()))
                {
                    this.GridView1.PageIndex = 0;
                    initChanceListInfoList();

                  
                }
             
            }
        }
    }

    #region 工具条事件(新建、打印)
    protected void Toolbar_ButtonClick(object sender, EventArgs e)
    {
        if (sender is Microsoft.Web.UI.WebControls.ToolbarButton)
        {
            ToolbarButton button = (ToolbarButton)sender;

            switch (button.ID)
            {
                case "newChanceList"://新建渠道明细
                    {
                        JS.OpenNewWindow("ChanceList.aspx?backindex=1&type=1&Chanceid=" + Request.QueryString["id"].Trim(), "", 300, 220, 400, 270);
                        break;
                    }
                case "printList"://打印查询结果
                    {
                        break;
                    }
                case "chanceInfo"://渠道信息
                    {
                        if (this.MultiView1.ActiveViewIndex != 0)
                        {
                            this.MultiView1.ActiveViewIndex = 0;
                        }
                        break;
                    }
                case "chanceListInfo"://渠道明细
                    {
                        if (this.MultiView1.ActiveViewIndex != 1)
                        {
                            this.MultiView1.ActiveViewIndex = 1;
                        }
                        break;
                    }
                case "ChanceExcel"://导出渠道列表
                    {
                        if (this.GridView1.Rows.Count == 0)
                        {
                            return;
                        }

                        DataTable ToExcelDataTable = DbHelperSQL.gettable(string.Format(strSqlQuery, "", "").Replace("TOP", ""));//导出Excel的DataTable

                        string[] listname = { "产品名称", "数量", "折扣", "总金额" };
                        string[] cols = { "PRODUCTNAME", "AMOUNT", "AGIO","MONEYSUM" };
                        ToExcel.tableToExcel(ToExcelDataTable, listname, cols);


                        break;
                    }
                default:
                    {
                        return;
                    }
             }
        }
    }
    #endregion 工具条事件(新建、打印)
    #region 初始化表格行事件
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int index = e.Row.RowIndex;
            if (index >= 0)
            {
                string cid = this.GridView1.DataKeys[index][0].ToString();


                string s1 = "window.open('ChanceList.aspx?Chanceid={0}&id={1}&backindex=1','','height=470,width=700,top=100,left=250,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes')";

                e.Row.Attributes.Add("ondblclick", string.Format(s1, Request.QueryString["id"].Trim(), cid));
                e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "return confirm('确定要永久删除该条记录吗?');");
            }
        }
    }
    #endregion 初始化表格行事件

    #region 表格记录的删除事件
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        if ((!JS.isCookiesAvailabile()))
        {
            return;
        }

        //this.GridView1.Rows[e.RowIndex].ToString()
        try
        {
            if (DbHelperSQL.ExecuteSql("DELETE FROM CHANCELIST WHERE CHANCEDETAILID = " + this.GridView1.DataKeys[e.RowIndex].Value) > 0)
            {
                this.initChanceListInfoList();
            }
            else
            {
                JS.Alert("删除记录失败,请稍候再试。");
            }
        }
        catch (Exception ex)
        {
            JS.Alert("删除记录失败,详细信息:" + ex.Message.Replace("\r\n", "").Replace("'", ""));
        }
    }
    #endregion 表格记录的删除事件

    #region 初始化渠道明细页面内容


    protected void initChanceListInfoList()
    {
        
        StringBuilder strSql = new StringBuilder("SELECT CHANCELIST.CHANCEDETAILID, CHANCELIST.AMOUNT, CHANCELIST.AGIO, CHANCELIST.MONEYSUM, PRODUCTS.PRODUCTNAME, CHANCELIST.PRODUCTID FROM PRODUCTS INNER JOIN CHANCELIST ON PRODUCTS.PRODUCTID = CHANCELIST.PRODUCTID WHERE CHANCELIST.CHANCEID =").Append(Request.QueryString["id"].Trim()).Append(" AND CHANCELIST.BCHANCE=").Append(Request.QueryString["type"].Trim());

        String strLevel = Request.Cookies["askCRM"]["LEVELID"];
        string strUid = Request.Cookies["askCRM"]["USERID"];

        if (string.IsNullOrEmpty(strLevel)
            || string.IsNullOrEmpty(strUid))
        {
            return;
        }

        strUid = Tools.Decrypt(strUid, Tools.myKey);
        strLevel = Tools.Decrypt(strLevel, Tools.myKey);

        switch (Convert.ToInt32(strLevel))
        {
            case 0://超级用户
                break;
            default://其他用户
                strSql.Append(" AND CHANCELIST.OPERATOR = '").Append(strUid).Append("'");
                break;
        }

        try
        {
            strSqlQuery = strSql.ToString();
            this.GridView1.DataSource = DbHelperSQL.gettable(strSql.ToString());
            this.GridView1.DataBind();
        }
        catch (Exception ex)
        {
            JS.Alert("初始化数据失败。详细信息:" + ex.Message.Replace("\r\n", "").Replace("'", ""));
            return;
        }
    }
    #endregion 初始化渠道明细页面内容
}