The. aspx code is as follows:
<%@ page language= "C #" autoeventwireup= "true" codefile= "Test.aspx.cs" inherits= "test"%><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><span style= "color: #ff0000;" >selectcommand= "SELECT * from [t_series] WHERE se_delete=false ORDER by Se_order DESC" to modify this statement, indicate that the Se_ Delete the item that is marked False. </span>
<span style= "color: #ff0000;" > commandargument= ' <% #Eval ("se_id")%> ' for parameter delivery </span>
The. Aspx.cs code is as follows:Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;using System.data.oledb;public Partial class test:system.web.ui.page{string str_cnn = "Pro vider=microsoft.jet.oledb.4.0; Data source= "; String str_sourcefile = "Mdb\\ev.mdb"; OleDbConnection CNN; OleDbCommand cmd; OleDbDataReader Datar; String Str_sql; protected void Page_Load (object sender, EventArgs e) {} protected void myCMD (object sender, CommandEventArgs e) { String str_conn = str_cnn + MapPath (str_sourcefile); CNN = new OleDbConnection (Str_conn); Cnn. Open (); Str_sql = "Update t_series set Se_delete =true where" + "se_id =" +<span style= "color: #ff0000;" > e.commandargument.tostring ();//Receive Parameters!!! </span> cmd = new OleDbCommand (Str_sql, CNN); Cmd. ExecuteNonQuery (); Cnn. Close (); <span style= "color: #ff0000;" >listview1.databind ();//Data Control insidebutton, you need to rebind the data control's data </span> after execution;}}
The effect is as follows:When clicked OK, this item is marked for deletion.
ListView Custom Button Instance-Tag Delete feature