Batch processing (addition and modification) using WebGrid
1. Principles and Use Techniques (1) WebGRID allows for the addition of allowing modifications to implement instant updates (2) Using SqlDataAdapter's Update method to update the data source to update the database. 2. Implementation Procedure (1) Add a webgrid (webgrid1) Setting its baseowaddNew, and allowedit's properties to true. (2) Specify the WebGrid's DataMember and add the columns you need to display for it. (3) Copy a WebGrid named WGRIDTMP with (WebGrid1). 3. The code is as follows. Private void bind {if (chkadd.checked == false {dataset dstmp = new dataset (); if (! Dstmp.tables.contains ("checks")) {dstmp.tables. Add (sqldst.Tables [ "checks"] Clone ().);} wgridtmp.DataSource = dstmp;} dg.DataSource = sqldst; dg.DataMember = "checks"; dg.DataBind ();} private void WebGrid1_AddRow (object Sender, isnet.Webui.Webgrid.Roweventargs e) {// (4DATAROW "E.row.DATAROW) ["checks_xmbh"]=this.txtXmbh.Text.trim (); DataSet DSX = (Dataset) WebGrid1.datasource; DataSet dst = (DataSet) wgridtmp.DataSource; dst.Merge (. dsx.Tables [ "checks"] GetChanges (System.Data.DataRowState.Added), false, System.Data.MissingSchemaAction.Add); wgridtmp.DataSource = dst } Private void save () {Try {dataset dstmp = (dataset) this.wgridtmp.datasource; if (dstmp! = Null) SqlDap.Update (DSTMP); else {response.write (msg.MessageBox ("data format, Length and range incorrect! "));}} Catch (sqlexception ex) {response.write (" data format, length and range incorrect, error number: " EX.NUMBER ", detail: " EXMESSAGE)); DataSet DSERR = (Dataset ) This.WebGrid1.DataSource; dserr.RejectChanges (); this.WebGrid1.DataSource = dserr; this.WebGrid1.DataBind ();} finally {setwgrid (this.WebGrid1, ""); settoolbar (this.Toolbar1, true) Sqldst.clear (); sqldap.fill (SqlDST, "Checks");}}