i want the coding for People can view the item which was added by them in the list..... [i need to add item in custom splist but that was not able to view by anyone...likewise people who are adding item in the same list which was not able to view by others(i gave permission to view my Splist for the user).]
If I understood you correctly you need to set up Item-level Permissions.
Go to list settings -> advanced settings and set Item-level Permissions Read: Read items that were created by the user .
Edit after Ksesh comment:
Also set Create and Edit access to : Create items and edit items that were created by the user
Edit programmatically in shortcut:
SPList spList = SPContext.Current.Web.Lists["MyList"]; spList.ReadSecurity = 2; spList.WriteSecurity = 2; spList.Update();
This can be done without any line of code also i.e. Item-level Permissions in order to do that
- Move to List Setting of said list.
- Move to views in the page.
- Click on "All Items".
- Move to the filter.
- check "Show items when the following is true"
- Put the condition Created By "Is equal To" TYPE([Me])
- Click on OK.
in short you need to put filter on public view for condition "Created By "Is equal To" TYPE([Me])"