日期:2014-05-17 浏览次数:20514 次
public partial class HpUpdate : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { rptBind(); } } protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "ImgbtnDelete") { HomePage model=new HomePage(); model.id=Convert.ToInt32(e.CommandArgument); new HomePageBll().HPDelete(model); rptBind(); } if (e.CommandName == "ImgbtnUpdate") { HomePage model = new HomePage(); model.id = Convert.ToInt32(e.CommandArgument); model.T_Field = ((TextBox)ListView1.EditItem.FindControl("txtField")).Text; model.T_Order = ((TextBox)ListView1.EditItem.FindControl("txtOrder")).Text; new HomePageBll().HpUpdate(model); ListView1.EditIndex = -1; rptBind(); } if (e.CommandName == "ImgbtnCancel") { ListView1.EditIndex = -1; rptBind(); } } private void rptBind() { ListView1.DataSource = new HomePageBll().GetAll(); ListView1.DataBind(); } protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e) { ListView1.EditIndex = e.NewEditIndex; } }
//应是这个 protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e) { ListView1.EditIndex = e.NewEditIndex; rptBind(); }