Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi..

I am getting a required values from dll and binding to an Ilist and from that Ilist i need a particular item to be removed like ex:

My Ilist contains fields Name,Place,Animal and Thing and many rows having the values like

Name Place Animal Thing
a aa aaa aaaa
b bb bbb bbbb

and so on..

Now i want to remove the entire Thing from this Ilist and all corresponding values and bind to new IList and use.
Please can u help me with this i have tried like using skip of linq and all but nothing has worked.. Please help
Posted
Comments
DamithSL 30-May-14 9:15am    
update the question with how you get the list of data and how you binding. and also include the code you tried to remove item.
Shruthi.BT 2-Jun-14 2:28am    
IList erContactsList = objContController.GetSearchContacts(EmployerGuid);

i am binding list like this and from GetSearchContacts i am getting all the values in which Place is also one of the them these values from list i am binding to grid view and i m trying to remove off that Place column completely from list and trying to bind to grid view but i am not able to get a proper solution.

1 solution

Here you go


Supose your list is mylist;

C#
newList= _mylist.Remove(a => a.Place == "aaa").ToList();


Here the items matching the criteria will be removed from _myList also.

If you want to maintain the original list and have a list not containing some items, then you need to assign the original list to another variable and remove items from there
i.e

C#
newList = _mylist;
newList.Remove(a => a.Place == "aaa").ToList();
 
Share this answer
 
Comments
Shruthi.BT 30-May-14 8:50am    
But i will need the value inside the place column and also i tried this i am not able to get a.Place in my code.. please help..
Naz_Firdouse 30-May-14 9:22am    
if your object contains a property called "Place" you will surely get a.Place when you access it.
Naz_Firdouse 30-May-14 9:23am    
can you share class which a list contains ?
Shruthi.BT 2-Jun-14 2:27am    
IList<businesslayer.contacts.searchcontact> erContactsList = objContController.GetSearchContacts(EmployerGuid);

i am binding list like this and from GetSearchContacts i am getting all the values in which Place is also one of the them these values from list i am binding to grid view and i m trying to remove off that Place column completely from list and trying to bind to grid view but i am not able to get a proper solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900