asp.net父窗体调用子窗体,并将值传回父窗体

来自MSDN代码~:

父窗体:




 



    在按钮中调用:



 子窗体前台代码:

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






   


   

                    SelectCommand="SELECT * FROM [Customers]">
   
   

                    DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" OnRowCreated="GridView1_RowCreated"
            OnRowDataBound="GridView1_RowDataBound">
           
               
               
               
               
               
               
               
               
               
               
               
           

       

   



后台代码:

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 GridViewClientClick : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType==DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("ondblclick", "ReKey('" + e.Row.Cells[2].Text+e.Row.Cells[1].Text+"')");
            //调用前台ReKey
            //e.Row.Attributes["style"] = "Cursor:hand";
            //键盘事件
            //e.Row.Attributes.Add("OnKeyDown", "GridViewItemKeyDownEvent('" + e.Row.Cells[1].Text + "')");

        }

    }
}

你可能感兴趣的:(.NET&C#)