Implement packet small schemes with DataTGrid

xiaoxiao2021-03-06  65

<% @ Page language = "c #" codebehind = "Webform6.aspx.cs" autoeventwireup = "false" inherits = "c4.webform6"%> summary rows </ title> <style> hr {color: black; height: 2px} .stdtextbox {border-right: black 1px solid; border-top: black 1px solid; font-size : X-Small; Filter: Progid: DxImageTransform.microsoft.dropshadow (Offx = 2, OFFY = 2, Color = 'Gray', Positive = 'True'); Border-Left: Black 1PX Solid; Border-Bottom: Black 1px Solid; font-family: verdana} .stdtext {font-size: x-small; font-family: verdana} </ style> <body bgcolor = "iVory" style = "font-size: small; font-family: Verdana "> - ASP.NET FORM -> <form runat =" server "id =" form1 "> <! - grid and the remain of the page -> <table> <tr> <td valign = "TOP"> <ask: DataGrid ID = "grid" runat = "server" autogeneratecolumns = "false" allowpaging = "true" pagesize = "10" cellspacing = "0" cellpadding = "0" cellpadding = "0" cellpadding = "0" cellpadding = "0" cellpadding = "0" cellpadding = " 4 "Datakeyfield =" MyCustomerid "Borders Tyle = "solid" bordercolor = "skyblue" borderwidth = "1" gridlines = "both"> <headerstyle backcolor = "skyblue" font-size = "9pt" font-bold = "true" /> <itemstyle backcolor = "# Eeeeee "/> <Pagerstyle BackColor =" skyblue "font-name =" Webdings "font-size =</p> <p>"10pt" PrevPageText = "3" NextPageText = "4" /> <Columns> <asp: BoundColumn DataField = "MyCustomerId" HeaderText = "Customer" /> <asp: BoundColumn DataField = "MyOrderId" HeaderText = "Order #" / > <Asp: boundcolumn datafield = "price" Headertext = "Amount" DataFormatString = "{0: C}"> <itemstyle horizontalalign = "right" /> </ asp: boundcolumn> </ color> </ asp: datagrid> </ td> <td valign = "TOP" width = "20"> </ td> <td valign = "top"> <b> year </ b> <ask: DropDownList runat = "server" id = "DDYEARS "> <Asp: listitem runat =" server "id =" Listitem1 "name =" listitem1 "> 1998 </ ask: listitem> <ask: listitem runat =" server "id =" listitem2 "name =" listitem2 "> 1997 </ asp: listitem> <ask: listitem runat = "server" id = "listitem3" name = "listitem3"> 1996 </ ask: listitem> <asp: dropdownloadList> <ask: linkbutton runat = "server" text = "Load ..." οnclick = "OnLoadYear" ID = "Linkbutton1" NAME = "Linkbutton1" /> <br> <br> <asp: label runat = "server" cssclass = "S TdText "ID =" lblmsg "/> </ td> </ tr> </ table> <hr> </ form> </ body> </ html> // cs code using system; using system.collections; using system .Componentmodel;</p> <p>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; using system.text; Namespace C4 {/// <summary> /// WebForm6 summary description. /// </ summary> public class WebForm6: System.Web.UI.Page {protected System.Web.UI.WebControls.DataGrid grid; protected System.Web.UI.WebControls.DropDownList ddYears; protected System.Web.UI. WebControls.LinkButton Linkbutton1; protected System.Web.UI.WebControls.Label lblMsg; (! IsPostBack) private void Page_Load (object sender, System.EventArgs e) {if {// Load data and refresh the view DataFromSourceToMemory ( "MyDataSet") ; UpdateDataView ();}} // DataFromSourceToMemory private void DataFromSourceToMemory (String strDataSessionName) {// Gets rows from the data source DataSet oDS = PhysicalDataRead (); // Stores it in the session cache Session [strDataSessionName] = oDS;}</p> <p>// PhysicalDataRead Private Dataset PhysicalDataRead () {string strcn = "server = localhost; initial catalog = northwind; uid = sa;"; sqlConnection conn = new SqlConnection (STRCNN);</p> <p>// Command Text Using With Rollup StringBuilder SB = New StringBuilder (""); sb.append ("SELECT"); sb.append ("Case Grouping (" Case Grouping ("Case Grouping (O.Customerid) When 0 Then O.CUSTOMERID ELSE ' End as mycustomerid, "); sb.append (" Case Grouping (odd.orderid) when 0 Then Od.Orderid else -1 end as myorderid, "); sb.append (" sum (od (od .quantity * @ ditprice) "); Sb.append (" from Orders O, [ORDER DETAILS] OD "); sb.append (" Where Year (ORDERDATE) = @Theyear and Od.Orderid = O.OrderID "); Sb.Append "GROUP BY O.CUSTOMERID, OD.Orderid with rollup"); sb.append ("Order By O.Customerid, Price"); string strcmd = sb.toString (); sb = null; sqlcommand cmd = new sqlcommand () ; Cmd.commandtext = strcmd; cmd.connection = conn;</p> <p>Sqldataadapter Da = new SqldataAdapter (); da.selectcommand = cmd;</p> <p>// Set the "year" parameter SqlParameter p1 = new SqlParameter ( "@ TheYear", SqlDbType.Int); p1.Direction = ParameterDirection.Input; p1.Value = Convert.ToInt32 (ddYears.SelectedItem.Text); cmd.Parameters .Add (p1); // the dataset contains1. // the latter is renamed to "orderssummary" and the two the customerid field. DataSet DS = New DataSet () DA.FILL (DS, "Orders");</p> <p>Return DS;} // Refresh THE UI Private Void UpdatedataView () {// Retrieves The Data Dataset DS = (Dataset) Session ["MyDataSet"]; DataView DV = DS.TABLES ["Orders"]. DefaultView;</p> <p>// RE-BIND DATA Grid.dataSource = DV; Grid.Database ();} #Region Web Form Designer Generated Code Override Protected Void OnInit (Eventargs E) {// // Codegen: This call is ASP.NET Web Form Designer is required. // InitializeComponent (); base.onit (e);} /// <summary> /// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// </ summary> private void InitializeComponent () {this.grid.ItemCreated = new System.Web.UI.WebControls.DataGridItemEventHandler (this.grid_ItemCreated); this.grid.PageIndexChanged = new System.Web.UI. WebControls.DataGridPageChangedEventHandler (this.grid_PageIndexChanged); this.grid.ItemDataBound = new System.Web.UI.WebControls.DataGridItemEventHandler (this.grid_ItemDataBound); this.Load = new System.EventHandler (this.Page_Load);} #endregion</p> <p>Private void Grid_Itemcreated (Object Sender, System.Web.ui.WebControls.DataGriditeMeventArgs E) {// Get The newly create it = E.Item.itemType;</p> <p>/// // ITEM and ALTERNATINGITEM if (itemType == ListItemType.Item || itemType == ListItemType.AlternatingItem) {DataRowView drv = (DataRowView) e.Item.DataItem; if (! Drv = null) {// Check here The app-specific way to detect WHETHER THE // CURRENT ROW Is A Summary Row</p> <p>IF ((int) DRV ["MyorderID"] == -1) {// Modify The Row Layout As Needed. in this case to White // Group THE FIRST TWO CELLS AND DISPLAY COMPANY name and #orders // Display the total of orders // Graphical manipulations can be done here. Manipulations that require // data access should be done hooking ItemDataBound. They can be done // in ItemCreated only for templated columns. e.Item . Backcolor = color.White; E.Item.Font.Bold = true; E.Item.cells.removeat (1); // Remove the Order # Cell E.Item.cells [0] .columnspan = 2; // Span the Custid Cell E.Item.cells [1] .hizontalalign = Horizontalalight.right;}}}}</p> <p>Private void Grid_pageIndexchanged (Object Source, System.Web.ui.WebControls.DataGridPageChangeDeventargs E) {grid.currentpageindex = E.NewpageIndex; UpdatedataView ();</p> <p>private void grid_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {// Retrieve the data linked through the relation // Given the structure of the data ONLY ONE row is retrieved DataRowView drv = e.Item (DataRowView) .Dataitem; if (DRV == Null) return;</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-92596.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="92596" 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.039</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 = '87I_2FNEI7XNwNx_2FktD8hlR7UL5AHyjFud1DXxeja_2FbVGDGlaOngEIc2b_2B_2FvkWv8ptfcqHd9dLTwOTjA_2BLlXTvpg_3D_3D'; 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>