ASP.NET―001:GridView绑定List、页面返回值具体实现(3)


            if (!IsPostBack)
            {
                dManager.DoAddPersons();


                this.dgPersons.DataSource = dManager.PersonCollect;


                this.dgPersons.DataBind();
            }
        }


        protected void Selcted_Click(object sender, EventArgs e)
        {
            int selectIndex = this.dgPersons.SelectedIndex;


            foreach (PersonModel mitem in dManager.PersonCollect)
            {
                if (mitem.PersonIndex - 1 == selectIndex)
                {
                    mitem.PersonSelected = true;
                }
                else
                {
                    mitem.PersonSelected = false;
                }
            }


            selectItem = dManager.PersonCollect[selectIndex];


            string vbCrLf = " ";


            string strScript = "<script>" + vbCrLf;


            strScript += "window.parent.returnValue='" + selectItem.PersonName + "';" + vbCrLf;


            strScript += "window.parent.close();" + vbCrLf;


            strScript += "</script>" + vbCrLf;


            if (!IsClientScriptBlockRegistered("clientScript"))
            {
                RegisterClientScriptBlock("clientScript", strScript);
            }
        }
    }

承载绑定页面的页面

复制代码 代码如下:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrameFrm.aspx.cs" Inherits="ASPNetGridView.Pages.FrameFrm" %>


<!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></title>
</head>
<frameset rows="0,*">
    <frame src="https://www.jb51.net/about:blank">
    <frame src="https://www.jb51.net/ChildFrm.aspx">
  </frameset>
</html>

主页面,获取返回值的js在前端

复制代码 代码如下:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPNetGridView._Default" %>


<!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></title>
</head>
<body>
    <div>
        <form runat="server" method="post">
            <table runat="server">
              <tr>
                  <td>
                  <asp:Label runat="server" Font-Bold="true">选择结果</asp:Label>
                  </td>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjzszx.html