请问怎么移除List中的类
请问怎么移除List中的类,帮忙看一下下面代码.程序代码:
public partial class operate : System.Web.UI.Page { private int id = 0; private List<Model.Keys> lists = null; public operate() { lists = new List<Model.Keys>(); } protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(Request.QueryString["id"].ToString(), out id)) id = 0; if (!IsPostBack) { lists = new SQLserverDAL.KeysDAL().Items(id, Convert.ToByte(DateTime.Now.AddMonths(-month).Month)); ViewState["lists"] = lists; this.list.DataSource = lists; this.list.DataBind(); } } protected void ReMove_Click(object sender, CommandEventArgs e) { int id = Convert.ToInt32(); lists = (List<Model.Keys>)ViewState["lists"]; lists.Remove(new SQLserverDAL.KeysDAL().Item(id)); ViewState["lists"] = lists; this.list.DataSource = lists; this.list.DataBind(); } }
lists.Remove(new SQLserverDAL.KeysDAL().Item(id))返回的总是False..请问是那个地方错误了.