How to create a chain list that uses a pop-up window to view details

xiaoxiao2021-03-05  22

How to create a hyperlink listing with a pop-up window: www.dotjunkie.com This article comes from a loyal DotNetJunkie suggestion. He initially sent us to us, ask us to give an example. To explain how to set up a chain of a new window that maps its details when the user can pop up in the DataGrid. Before we replied to him, he had provided us with a way and suggested that we write a tutorial. So this article. This article contains two WebForms and a CSS first WebForm contains a DataGrid, which shows a product in the Northwind database and hyperlinks written "Seedetails". As long as you click on this link, you will call JavaScript's Window.Open method to open a new window. In a URL contains the Query String parameter of the product of the product you want to know in detail. In the second WebForm, it is another DataGrid that shows all the details of the product selected by the user. Let us now look at Webform1.aspx and WebForm1.aspx.cs. Webform1.aspx <% @ page language = "c #" autoeventwireup = "false" inherits = "Howtos.DataGrid.popupwindow.webform1"%>

WebForm1.aspx.cs using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System. Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace HowTos.DataGrid.PopupWindow {public class WebForm1: System.Web.UI.Page {protected System.Web.UI.WebControls. DataGrid DataGrid1; #region User Defined Code private void Page_Load (object sender, System.EventArgs e) {if this.BindData () (this.IsPostBack!);} protected void BindData () {SqlCommand cmd = new SqlCommand ( "SELECT TOP 10 ProductID, ProductName FROM Products ", con (" Server = LocalHost; DataBase = Northwind; TRUSTED_CONNECTION = TRUE ")); this.DataGrid1.DataSource = cmd.ExecuteReader (CommandBehavior.CloseConnection); this.DataGrid1.DataBind ();} Protected SqlConnection Con (System.String Connectionstring) {SqlConnection C = New SqlConnection (Connectionstring); C.Open (); Return C; } #Endregion #region Web Form Designer generated code override protected void OnInit (EventArgs e) {InitializeComponent (); base.OnInit (e);} private void InitializeComponent () {this.Load = new System.EventHandler (this.Page_Load } #ENDREGON}} In fact, these two files have no difficulties, except DataNavigateURLFORMATSTRING, you noticed that I wrote JavaScript window.open (note: I can also build a JS file or use