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

zhaozj2021-02-16  58

How to create a hyperlink with a pop-up window to view the details: www.dotnetjunkie.com

This article comes from a loyal DotNetJunkie suggestion. He initially sent an email to us, asking us to give an example to explain how to set up a new window that displayed in Details when the user clicks in DataGrid. The chain list. 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.ispostback). Binddata ();

}

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; C.Open (); Return C;

}

#ndregion

#Region Web Form Designer Generated Code

Override protected void oninit (Eventargs E) {InitializationComponent (); Base.onit (E);}

Private vidinitis () {this.load = new system.eventhandler (this.page_load);

#ndregion

}

In fact, this two files have no difficulty. In addition to DataNavigateURLFORMATSTRING, you noticed that I will write JavaScript window.open directly (note: I can also build a JS file or use