Friday, 18 October 2013

How to get list item url in Editmode or Displaymode in sharepoint 2010

Below given code works fine to get the list item url in Edit Form :

string listItemUrl = string.Format("{0}{1}?ID={2}", properties.WebUrl, splist.DefaultEditFormUrl, spListItem.ID);

In the above code:

  • properties.WebUrl gets the Current Web url. Ex: http://SharepointSite:8888.
  • splist.DefaultEditFormUrl gets the given list url. Ex/Lists/YourListName/EditForm.aspx. If your want to use display form then you can use splist.DefaultDisplayFormUrl instead of edit form.
  • spListItem.ID gets the list item ID to which you want to edit.

Below given code works fine to get the list item url in Display Form :

string listItemUrl = string.Format("{0}{1}?ID={2}", properties.WebUrl, splist.DefaultEditFormUrl, spListItem.ID);

No comments:

Post a Comment

Total Pageviews