开发者

add entity to the end of bindinglist cause updating previous entities

开发者 https://www.devze.com 2023-01-31 13:22 出处:网络
I read my records from database and restore in binding list. now I want to add new entitys to my bindinglist but It dosent work.

I read my records from database and restore in binding list. now I want to add new entitys to my bindinglist but It dosent work. when I add a first entity There is no problem. after that for each entity I insert, my previous entitys change to last entity. I ts like that every entitys are point to one entity, and when I add new entity every entities change and update to new value. here is my code.

                My_Entity _Entity;
                BindingList<My_Entity> List;
                 //====================================
                List = businessLogic.SelectAll();//fill list
                 //===============================================开发者_开发百科
                _Entity = new My_Entity();
                _Entity = get_data(); //fill entity here
                businessLogic.Entity = _Entity;
                if (businessLogic.SendToInsert())
                {
                    List.Add(_Entity);

                }

where is the problem ?


thanks every body. The Entity in Get_Data() Method. didnt be new in each time I call it. I new that entity and the problem is solved .


try with below settings

BindingList<My_Entity> List ;
List.AllowNew = true;
List.AllowEdit = true;
List.AllowRemove = true;
0

精彩评论

暂无评论...
验证码 换一张
取 消