Take the implementation code as the Northwind database in SQL2000.
// WebForm1.aspx code
<% @ Page language = "c #" codebehind = "Webform1.aspx.cs" autoeventwireup = "false" inherits = "Demoportal.Webform1"%>
Webform1 </ Title> <style type =" text / css "> A: link {color: # 000000; text-decoration: none} a: active {color: # 000000 Text-Decoration: none} A: visited {color: # 000000; text-decoration: none} a: hover {color: # 4455aa; text-decoration: underline} body {scrollbar-fold-color: # dee3e7; font- SIZE: 11px; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: # dee3e7; COLOR: # 000000; SCROLLBAR-3DLIGHT-COLOR: # d1d7dc; SCROLLBAR-ARROW-COLOR: # 006699; SCROLLBAR-TRACK-COLOR : #efefef; Font-Family: Verdana, Song; ScrollBar-Darkshadow-Color: # 98aab1} font {line-height: Normal} TD {font-size: 11px; line-height: 15px; font-family: Verdana, Song } TH {font-weight: bold; font-size: 12px; Background-Image: URL (Skins / Default / CSS / Default / bg1.gif); Color: White; Background-Color: # 4455aa} td.tabletitle2 {b ACKGROUND-COLOR: # e4e8ef} TD.TableBody1 {LINE-HEIGHT: normal; BACKGROUND-COLOR: #ffffff} TD.TableBody2 {LINE-HEIGHT: normal; BACKGROUND-COLOR: # e4e8ef} TD.TopDarkNav {BACKGROUND-IMAGE: url (Skins / default / css / default / topbg.gif)} TD.TopLighNav {BACKGROUND-IMAGE: url (Skins / default / css / default / bottombg.gif)} TD.TopLighNav1 {BACKGROUND-IMAGE: url (Skins / default /cs/default/tabs_m_tile.gif)} Td.toplight: #ffff} .tableborder1 {Border-Right: 1PX; Border-top: 1px; Border-Left: 1px; Width: 98%; Border-bottom : 1px; Background-Color: # 6595d6} .tableborder2 {border-right: #dedede 1px solid;</p>
<p>Border-top: #dededede 1px solid; border-left: #dededE 1px solid; width: 98%; border-bottom: #dedededE 1px solid; background-color: #efefef} #tabletitlelink A: link {color: #ffffff; TEXT-DECORATION: NONE} # {color: #fffff; text-decoration: none} #tabletitlelink A: Active {color: #ffff; text-decoration: none} #tabletitlelink A: Hover {color: #fffff Text-decoration: underline} INPUT {font-size: 12px; color: # 000000; line-heiGHT: 15px; font-family: Tahoma, Verdana, "Song"} Select {Font-size: 12px; color: # 000000 Line-height: 15px; Font-Family: Tahoma, Verdana, "Song"} Textarea {Font-Size: 12px; Color: # 000000; Line-Height: 15px; Font-Family: Tahoma, Verdana, "Song"} Option {font-size: 12px; color: # 000000; line-heiGHT: 15PX; Font-Family: Tahoma, Verdana, "Song"} .NORMALTEXTSMALL {Font-size: 11px; color: # 000000; Font-Family: Verdana Arial, Helvetica, Sans-Serif} .menuskin {Border-Right: # 666666 1px solid; border-top: # 666666 1px solid; Background-Image: URL (Skin s / Default / dvmenubg3.gif); VISIBILITY: hidden; FONT: 12px Verdana; BORDER-LEFT: # 666666 1px solid; BORDER-BOTTOM: # 666666 1px solid; BACKGROUND-REPEAT: repeat-y; POSITION: absolute; BACKGROUND- Color: #efefef} .menuskin A {Padding-Right: 10px; Padding-Left: 25px; Behavior: URL (INC / NOLINE.HTC); Color: Black; Text-Decoration: none} # MouseOverStyle {Border-Right: # 597DB5 1PX Solid; Padding-Right: 0px; Border-top: # 597db5 1px Solid; Padding-Left: 0px; padding-bottom: 0px; margin: 2px; border-left: # 597db5 1px solid; padding-top: 0px; Border-bottom: # 597db5 1px solid; background-color: # c9d5e7} # mouseOversty a {color: black} .menuitems {padding-right: 1px; padding-ip: 1px; padding-bottom: 1px;</p>
<p>Margin: 2px; Word-Break: Keep-all; Padding-top: 1px} a.navlink: link {color: # 000000; Text-Decoration: none} a.navlink: visited {color: # 000000; Text-Decoration: None} a.navlink: hover {color: # 003399; text-decoration: none} .brightclass {background-color: # d7d7d7} div.quote {border-right: #cccccc 1px solid; padding-right: 5px; border- Top: #cccccc 1px solid; padding-left: 5px; background: # f3f3f3; padding-bottom: 5px; margin: 5px 20px; border-left: #cccccc 1px solid; line-height: Normal; Padding-top: 5px; Border-bottom: #cccccc 1px solid} div.htmlcode {border-right: #ccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 5px; font-size: 12px; background : #fdfddf; padding-bottom: 5px; margin: 5px 20px; overflow: auto; border-left: #cccccc 1px solid; line-height: Normal; Padding-top: 5px; border-bottom: #cccccc 1px solid; font -Family: ncursive} </ style> <meta name = "generator" content = "Microsoft Visual Studio .NET 7.1> <meta name =" code_language "c Ontent = "C #"> <meta name = "vs_defaultclientscript" Content = "javascript"> <meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5> </ head> <body > <Form id = "form1" method = "post" runat = "server"> <ask: button id = "BN_DEMO" style = "z-index: 102; Left: 32px; position: absolute; top: 16px" Runat = "Server" text = "demo"> </ asp: button> <Table> <Tr> <TD> <asp: DataGrid ID = "DG_ORDER" style = "z-index: 101; Left: 32px; Position: absolute ;</p>
<p>TOP: 56px "runat =" server "ShowHeader =" False "AutoGenerateColumns =" False "> <Columns> <asp: BoundColumn DataField =" OrderID "Visible =" False "> </ asp: BoundColumn> <asp: BoundColumn DataField = "OrderDate" Visible = "False"> </ asp: BoundColumn> <asp: BoundColumn DataField = "RequiredDate" Visible = "False"> </ asp: BoundColumn> <asp: BoundColumn DataField = "ShippedDate" Visible = "False" > </ asp: boundcolumn> <ask: BoundColumn Datafield = "freight" Visible = "false"> </ ask: BoundColumn> <asp: templateColumn> <itemtemplate> <table> <TR> <TD> <asp: label id = "Lb_orderdate" runat = "server"> 2004-07-15 </ ask: label> <ask: label id = "lb_requireddate" runat = "server"> 2004-07-15 </ asp: label> <asp: Label ID = "lb_shippedddate" runat = "server"> 2004-07-15 </ ask: label> <ask: label id = "lb_freight" runat = "server"> 2004-07-15 </ ask: label> < / TD> </ tr> <tr> <td> <Tab Le> <TR> <TD> <asp: DataGrid ID = "DG_Category" AutoGenerateColumns = "false" runat = "server" showheader = "false"> <columns> <ask: BoundColumn Datafield = "</p>
<p>CategoryID "Visible =" False "> </ asp: BoundColumn> <asp: BoundColumn DataField =" OrderID "Visible =" False "> </ asp: BoundColumn> <asp: BoundColumn DataField =" CategoryName "ItemStyle-Font-Bold = "True" ItemStyle-HorizontalAlign = "Center" ItemStyle-VerticalAlign = "Middle"> <ItemStyle Width = "120px"> </ ItemStyle> </ asp: BoundColumn> <asp: TemplateColumn> <ItemTemplate> <table> <tr> <td> <asp: DataGrid ID = "DG_OrderDetail" AutoGenerateColumns = "False" Runat = "server" ShowHeader = "False"> <Columns> <asp: BoundColumn DataField = "productname"> <ItemStyle Width = "300px"> < / ItemStyle> </ ask: BoundColumn> <asp: boundcolumn datafield = "unitprice"> <itemstyle width = "90px"> </ itemstyle> </ Asp: BoundColumn> <asp: BoundColumn DataField = "quantity"> <ItemStyle Width = "50px"> </ ItemStyle> </ asp: BoundColumn> <asp: BoundColumn DataField = "discount"> <ItemStyle Width = "40px > <</p>
<p>/ ItemStyle> </ ask: BoundColumn> </ columns> </ ask: DataGrid> </ td> </ tr> </ table> </ itemtemplate> </ asp: templateColumn> </ columns> </ asp: datagrid > </ Td> </ tr> </ Table> </ td> </ tr> </ table> </ itemtemplate> </ ask: templatecolumn> </ color> </ asp: datagrid> </ td> < / TR> </ table> </ form> </ body> </ html> // Webform1.aspx.cs code</p>
<p>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;</p>
<p>Namespace Demoportal {///</p>
<p>/// WebForm1 summary description. ///</p>
<p>Public class Webform1: System.Web.ui.page</p>
<p>{</p>
<p>Protected system.web.ui.webcontrols.button bn_deemo;</p>
<p>Protected system.web.ui.webcontrols.dataGrid DG_ORDER;</p>
<p>SqlConnection CN; // Global Data Connection Private Void Page_Load (Object Sender, System.EventArgs E) {// Place the user code here to initialize the page CN = New SqlConnection ("Server = (local); database = northwind; uid = SA; PWD = 4118615 ");</p>
<p>#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///</p>
<p>/// Designer supports the required method - Do not use the code editor to modify the // / this method. ///</p>
<p>Private vidinitiRizeComponent ()</p>
<p>{</p>
<p>THIS.BN_DEMO.CLICK = New System.EventHandler (this.bn_demo_click); this.Load = New System.EventHandler (this.page_load);</p>
<p>} #Endregion</p>
<p>private void Bn_Demo_Click (object sender, System.EventArgs e) {// get the order data sets SqlDataAdapter SqlDa = new SqlDataAdapter ( "select * from orders order by orderdate", Cn); DataSet ds = new DataSet (); SqlDa.Fill ( DS);</p>
<p>// Set the binding function this.dg_order.itemdatabase = new DataGriditeMeventHandler (DG_ORDER_ITEMDATABOUND);</p>
<p>// Bind display control this.dg_order.datasource = DS; this.dg_order.database ();</p>
<p>private void DG_Order_ItemDataBound (object sender, DataGridItemEventArgs e) {// Header Analyzing is listed or if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {Label Lb_OrderDate = ( Label) (E.Item.cells [5] .FindControl ("lb_orderdate"); label lb_requireddate = (Label) (E.Item.cells [5] .findControl ("lb_requireddate"); label lb_shippedDate = (label) (E.Item.cells [5] .FindControl ("lb_shippedddate"); label lb_freight = (Label) (E.Item.cells [5] .FindControl ("lb_freight");</p>
<p>LB_ORDERDATE.TEXT = "Order:" E.Item.cells [1] .text; lb_requireddate.text = "交 交:" E.Item.cells [2] .Text; lb_shippedddate.text = "Survey: " E.Item.cells [3] .Text; lb_freight.text =" Air freight: " E.Item.cells [4] .Text;</p>
<p>// Bind product category string strorderid = E.Item.cells [0] .text; string strsql = "Select Distinct a.categoryID, A.CategoryName, C.Orderid from categories A, Products B, /" ORDER DETAILS / " c where a.categoryid = b.categoryid and b.productid = c.productid and c.orderid = " strOrderID; SqlDataAdapter SqlDa = new SqlDataAdapter (strSQL, Cn); DataSet ds = new DataSet (); SqlDa.Fill (ds );</p>
<p>// Take the DataGrid bound IF (DS.TABLES [0] .Rows.count> 0) {DataGrid DG_Category = (DataGrid) (E.Item.cells [5] .FindControl ("DG_Category"); DG_Category.ItemDatabaseD = New DataGriditeMeventHandler (DG_CATEGORY_ITEMDATABOUND); DG_CATEGORY.DASOURCE = DS; DG_Category.database ();}}}</p>
<p>private void DG_Category_ItemDataBound (object sender, DataGridItemEventArgs e) {// Header Analyzing is listed or if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {// check product Single subtle category string strorderid = E.Item.cells [1] .text; string strcategoryId = E.Item.cells [0] .text; string strsql = "Select B.ProductName, C.Unitprice, C.quantity, C. discount from categories a, products b, / "order details /" c where a.categoryid = b.categoryid and b.productid = c.productid and c.orderid = " strOrderID " and b.categoryid = " strCategoryID;</p>
<p>Sqldataadapter Sqlda = New SqldataAdapter (strsql, cn); DataSet DS = New Dataset (); Sqlda.Fill (DS);</p>
<p>// Take the DataGrid bind IF (DS.Tables [0] .Rows.count> 0) {dataGrid DG_OrderDetail = (DataGrid) (E.Item.cells [3] .FindControl ("DG_ORDERDETAIL"); DG_ORDERDETAIL.DataSource = DS; DG_ORDERDETAIL.DATABIND ();} // No title bar, Tooltip prompt E.Item.Tooltip = "Goods: name, price, quantity, discount";}}}</p></div><div class="text-center mt-3 text-grey">
转载请注明原文地址:https://www.9cbs.com/read-16825.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>)
</div><div></div></div></div><ul class="postlist list-unstyled">
</ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="16825" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved
</div><div class="col text-right">Processed:
<b>0.059</b>, SQL:
<b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script>
var debug = DEBUG = 0;
var url_rewrite_on = 1;
var url_path = './';
var forumarr = {"1":"Tech"};
var fid = 1;
var uid = 0;
var gid = 0;
xn.options.water_image_url = 'view/img/water-small.png';
</script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script>
var forum_url = 'list-1.html';
var safe_token = 'cjmSuxFJnBjwYslueUO5LOG4aII8Je_2By3EplO_2FBQ2M7pF9XzgMJEawQ7G_2FexG_2B8aYr7JD7FRO8LUn0wU';
var body = $('body');
body.on('submit', '#form', function() {
var jthis = $(this);
var jsubmit = jthis.find('#submit');
jthis.reset();
jsubmit.button('loading');
var postdata = jthis.serializeObject();
$.xpost(jthis.attr('action'), postdata, function(code, message) {
if(code == 0) {
location.reload();
} else {
$.alert(message);
jsubmit.button('reset');
}
});
return false;
});
function resize_image() {
var jmessagelist = $('div.message');
var first_width = jmessagelist.width();
jmessagelist.each(function() {
var jdiv = $(this);
var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width();
var jmessage_width = Math.min(jdiv.width(), maxwidth);
jdiv.find('img, embed, iframe, video').each(function() {
var jimg = $(this);
var img_width = this.org_width;
var img_height = this.org_height;
if(!img_width) {
var img_width = jimg.attr('width');
var img_height = jimg.attr('height');
this.org_width = img_width;
this.org_height = img_height;
}
if(img_width > jmessage_width) {
if(this.tagName == 'IMG') {
jimg.width(jmessage_width);
jimg.css('height', 'auto');
jimg.css('cursor', 'pointer');
jimg.on('click', function() {
});
} else {
jimg.width(jmessage_width);
var height = (img_height / img_width) * jimg.width();
jimg.height(height);
}
}
});
});
}
function resize_table() {
$('div.message').each(function() {
var jdiv = $(this);
jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>');
});
}
$(function() {
resize_image();
resize_table();
$(window).on('resize', resize_image);
});
var jmessage = $('#message');
jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); });
jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); });
$('#nav li[data-active="fid-1"]').addClass('active');
</script>