I have a webpart that renders random list items (from any list and list type) in a specified format. I want the items that are being displayed in the webpart to link to their ListItem detail views. However, I don’t see a property on the list itself that would tell me what view is the default DETAIL view for the list (ie. blog list detail is Post.aspx). Does this come from the list definition? How would I get that information programmatically? I’m trying to avoid hard-coding any list information based on list type.
Share
Have a look at
SPList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url.I think this is what you’re looking for. You’ll need to append the the SPListItem.ID on the querystring so that it knows which list item to display.
It’s also a good practice to append
&Source=/url/to/current/pageto the querystring so that users will be redirected back to the page they left when they click the Cancel/Close buttons on the Edit or Display forms.