[Original] DataGrid front desk modification data, not refreshing the page

xiaoxiao2021-03-05  26

#Region statement // --------------------------------------------- ------------------------ //// Modification: Li Wei (Nick.lee) //// DataGrid front desk modified data, not refreshing the page

// Time: 2005-04-05

// Boyorgril@msn.com// qq: 16503096 // Note: Please indicate the modified place, thank you // ------------------------- -------------------------------------------- # endregion

Webform3.aspx <% @ page language = "c #" codebehind = "Webform3.aspx.cs" autoeventwireup = "false" inherits = "WebApplication1.webform3"%> Webform3 </ title> <meta http-equiv =" content-type "content =" text / html; charSet = GB2312> <meta name = "generator" Content = "Microsoft Visual Studio .NET 7.1"> <meta name = "CODE_LANGUAGE" Content = "C #"> <meta name = "vs_defaultClientScript" content = "JavaScript"> <meta name = "vs_targetSchema" content = "http: / / schemas.microsoft.com/intellisense/ie5 "> <script language =" javascript "src =" ./ gridclick.js "> </ script> </ head> <body> <form id =" Form1 "Method =" POST "Runat =" Server "> <ask: DataGrid ID =" DataGrid1 "runat =" server "bordercolor =" # 3366cc "bordersty =" none "borderwidth =" 1px "backcolor =" white "cellpadding =" 4 "font- Size = "9pt" width = "100%" horizontalalign = "center"> <selecteditemstyle font-bold = "true" forecolor = "# ccff99" backcolor = "# 009999"> </ selecteditemstyle> <itemstyle horizonta Lalign = "center" forcolor = "# 003399" backcolor = "white"> </ itemStyle> <headersty font-bold = "true" horizontalalign = "center" forcolor = "# ccccff"</p> <p>BackColor = "# 003399"> </ HeaderStyle> <FooterStyle ForeColor = "# 003399" BackColor = "# 99CCCC"> </ FooterStyle> <PagerStyle HorizontalAlign = "Left" ForeColor = "# 003399" BackColor = "# 99CCCC" Mode = "NumericPages"> </ PagersTyle> </ ask: DataGrid> </ form> </ body> </ html> Background CS file Using system; use system.collections; using system.componentmodel; using system.data; using system.data; . Drawing; use system.Web.SessionState; using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.htmlcontrols;</p> <p>A summary description of Namespace WebApplication1 {/// <summary> /// WebForm3. /// </ summary> public class WebForm3: System.Web.UI.Page {protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlConnection sqlConnection1; protected WebApplication1.DataSet1 dataSet11; protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load (object sender, System.EventArgs e) {// Put user code to initialize the page here this.sqlDataAdapter1.Fill (this.dataSet11 This.DataGrid1.datasource = this.dataset11.tables [0]; this.Database ();}</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);} /// <summary> /// Designer Supports the required method - Do not use the code editor to modify the // / this method.</p> <p>/// </ summary> private void InitializeComponent () {this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter (); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand (); this.sqlConnection1 = new System. Data.SqlClient.SqlConnection (); this.dataSet11 = new WebApplication1.DataSet1 ();. ((System.ComponentModel.ISupportInitialize) (this.dataSet11)) BeginInit (); // // sqlDataAdapter1 // this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1; this.sqlDataAdapter1.TableMappings.AddRange (new System.Data.Common.DataTableMapping [] {new System.Data.Common.DataTableMapping ( "Table", "Categories", new System.Data.Common.DataColumnMapping [ ] {New system.data.common.datacolumnMapping ("categoryid", "categoryid"), new system.data.common.datacolumnmapping ("categoryName", "categoryName", new System.Data.Common.DataColumnMapping ( "Description", "Description"), new System.Data.Common.DataColumnMapping ( "Picture", "Picture")})}); // // sqlSelectCommand1 // this.sqlSelectCommand1 .CommandText = "SELECT TOP 10 CategoryID, CategoryName, Description, Picture FROM Categories"; this.sqlSelectCommand1.Connection = this.sqlConnection1; // // sqlConnection1 // this.sqlConnection1.ConnectionString = "workstation id = /" STAR-NICK / "; packet size = 4096; user ID = sa; data source = /" (local) / "; pers" </p> <p>"IST security info = false; initial catalog = northwind; pwd = sa"; // // DataSet11 // this.dataset11.datasetName = "dataset1"; this.dataset11.locale = new system.globalization.cultureInfo ("zh- CN "); this.DataGrid1.ItemDataBound = new System.Web.UI.WebControls.DataGridItemEventHandler (this.DataGrid1_ItemDataBound); this.Load = new System.EventHandler (this.Page_Load); ((System.ComponentModel.ISupportInitialize) (this.dataset11)). Endinit ();} #ENDREGION</p> <p>private void DataGrid1_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.Item) {for (int i = 0 i <E.Item.cells.count; i ) {E.Item.cells [i] .attributes ["onclick"] = "editcell (this);";}}}}}</p> <p>CSS file:</p> <p>. INPUT1 {Border-Right: Black 1PX SOLID; Border-top: Black 1PX Solid; Font-size: 9pt; Border-Left: Black 1PX Solid; Color: Black; Border-Bottom: Black 1PX Solid; Background-Color: White }</p> <p>Border-top: Black 0px Solid; font-size: 9pt; border-left: black 0px solid; color: black; border-bottom: black 1px solid; background-color: White, BACKGROUND }</p> <p>Scripted file: / ** * <p> Title: DataGrid Click Edit (Do not refresh page) </ p> * <p> Description: Implement DataGrid Click Edit (Do not refresh page) </ p> * <p> Copyright: 2005 -2005 by mail_ricklee corporation </ p> * <p> Company: mail_ricklee corporation </ p> * <p> CreateTime: 2005-04-05 11:30 </ p> * <p> modifytime: </ p> * @CreateAuthor Miao Li * @version 1.0 * @ModifyAuthor * @version 1.0 * / function editCell (cell) {if (document.all) {cell.innerHTML = '<INPUT ID = "editCell" ONCLICK = "event.cancelBubble = true "Onchange =" setcell (this.parentelement, this.value "" onblur = "setcell (this.parentelement, this.Value)" value = " Cell.innertext '" size = "' Cell.innertext. Length '""; document.all.editcell.focus (); document.all.editcell.select ();} else if (document.getlementByid) {cell.Normalize (); var input = document.createElement (' INPUT '); input.setAttribute (' value ', cell.firstChild.nodeValue); input.setAttribute (' size ', cell.firstChild.nodeValue.length); input.onchange = function (evt) {setCell (this.parentNode , this.Value);}; input.o Nclick = function (evt) {evt.cancelbubble = true; if (evt.stoppropagation) evt.stoppropagation ();}; cell.replacechild (Input, cell.firstchild); input.focus (); input.select (); }</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-35521.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="35521" 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.031</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 = '6Mvkwaxhhm8BV6wL8GsQIEIqGN3wL93IpxL8iJHl2ZcvQop74JOD9nxXM5H2TVcqY7WJD71LcZA3d9T_2BmIsmsQ_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>