Create a pop-up window in DataGrid This article comes from DotNetJunkie. He originally writes the letter to provide an example of how to create HyperLinkColumn in DataGrid, you can open a new window after the user clicks this column, showing the details of this column. We have answered them through Email, he suggested that we have added this method to their guidelines, so there is this article. Like our original article, it is very simple, but simple-containing method examples can sense developers more effectively. This example contains two WebForms and a CSS file (all code can be downloaded) - the first WebForm contains a DataGrid of the product list read from the Northwind library, and HyperLink's State is set to "SEEDETAILS", once this The link is clicked, and the JavaScript clip will call. The user wants to get the product's ProductID as a parameter in the URL. The second WebForms containing another DataGrid lists all the specific users of the product. detail.
Let's take a look at DataGrid-Open.aspx.csdataGrid-open.aspx.csdataGrid-open.aspx <% @ page language = "c #" codebehind = "DataGrid-open.aspx.cs" autoeventwireup = "inherits =" Study.DataGrid_open "%>
"ITemStylehyperLink" /> (.../columns>/asp:dataGrid> "/HTMLDATAGRID-Open.aspx.csusing system; using system.collections; using system.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System. Data.SqlClient; Namespace Study {///
protected void BindData () {SqlCommand cmd = new SqlCommand ( "SELECT TOP 10 ProductID, ProductName FROM Products", con ( "Server = dwserver; DataBase = Northwind; User Id = sa; Password = 123456")); 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 OnNit (Eventargs E) {// // Codegen: This call is necessary for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///
In addition to DataNavigateURLFORMATSTRING, there is no difficulty, you can notice that I actually use a JavaScript clip (Note: You can also create a .js file or use