protected void favorites_ItemCommand(object sender, DataListCommandEventArgs e) { int favoriteId = (int)this.favorites.DataKeys[e.Item.ItemIndex]; if (e.CommandName == "Edit") { this.favorites.EditItemIndex = e.Item.ItemIndex; this.BindList(); } if (e.CommandName == "Cancel") { this.favorites.EditItemIndex = -1; this.BindList(); } if (e.CommandName == "Update") { TextBox box = (TextBox)e.Item.FindControl("txtTags"); TextBox box2 = (TextBox)e.Item.FindControl("txtRemark"); if (box.Text.Length > 100) { this.ShowMessage("修改商品收藏信息失败,标签信息的长度限制在100个字符以內", false); return; } if (box2.Text.Length > 500) { this.ShowMessage("修改商品收藏信息失败,备注信息的长度限制在500個字符以內", false); return; } if (CommentsHelper.UpdateFavorite(favoriteId, Globals.HtmlEncode(box.Text.Trim()), Globals.HtmlEncode(box2.Text.Trim())) > 0) { this.favorites.EditItemIndex = -1; this.BindList(); this.ShowMessage("成功的修改了收藏夹的信息", true); } else { this.ShowMessage("没有修改你要修改的內容", false); } } if (e.CommandName == "Deleted") { if (CommentsHelper.DeleteFavorite(favoriteId) > 0) { this.BindList(); this.ShowMessage("成功删除了选择的收藏商品", true); } else { this.ShowMessage("删除失败", false); } } }