ListView里的ItemCommand--笔记

        protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "EnableUr")
            {
                //int index = ((ListViewDataItem)e.Item).DisplayIndex;
                //Guid id = (Guid)ListView1.DataKeys[index].Value;
                int index = ((ListViewDataItem)e.Item).DisplayIndex;
                Guid id = (Guid)ListView1.DataKeys[index].Value;
                T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                adapter.EnableUrById(id);
                ListView1.DataBind();
            }
            else if (e.CommandName == "DisableUr")
            {
                int index = ((ListViewDataItem)e.Item).DisplayIndex;
                Guid id = (Guid)ListView1.DataKeys[index].Value;
                T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                adapter.DiableUrById(id);
                ListView1.DataBind();
            }
        }

  


posted @ 2012-07-18 20:05  liqipeng  阅读(277)  评论(0编辑  收藏  举报