Display a single listitem

Display a single listitem

You can display multiple list items with SharePoint and SharePoint Designer quite easy. But how do you display a single listitem? I worte a Webpart, which does this. If there are more than one listitem, you can page through them. And if you like, you can pass an itemid via a Webpart connection.

In the Webpart properties you can select the list/library. If you like, you can specify a view other than the default view.

SafeControl Entry for your web.config:
<SafeControl  Assembly="RH.DisplayListItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7850e867f7381714"  Namespace="RH"  TypeName="*"  Safe="True" />

 Download Webpart
 
Download Webpart Source

5 Comments

vijai

Reply

Hi,

Thanks for valuable webpart, as I am looking for the same, I am very thankful to you if could help me on how to place the Submit and Cancel buttons, so that I cab edit and submit the items. I have changed the SPControlMode as Edit, I can see the values populated into the appropriate fields, but I am unable to submit the changes becoz of no Submit button, So please help

 

René Hézser

Reply

Hi Vijai,
add a button to the controls. Then go through the controls, and assign their values to the corresponding field of the listitem.
item[field.id] = GetSharePointContorlValue(Controls, field);
You can use my webcontrols class –> http://www.hezser.de/blog/archive/2007/04/29/how-to-use-the-sharepoint-web-controls.aspx

René

 

bert

Reply

Hi,

the web part is really nice, I am trying to use it for editing as well. However if I put the controls in Edit mode I have an issue. The values are loaded for the first item, when I use paging to go to the next item the editable fields are not loaded. In display mode everything works perfect.

Kind Regards

 

Jason

Reply

Hi, I added the dll to the GAC and added the Safe Control to the relavent Web App. I then populate the web part library all ok. When i try to add the webpart i come out with “Unable to add selected web part(s). An error has occured”. Can you let me know what i am doing wrong? Or where in specific do i put the dll and which web.config to modify?

 

Toby

Reply

Same problem here: I get an error message when trying to add the webpart. Log says: Failed to add webpart http%253A%252F%252FXXXXX.XXXXXXXX.XXXXX%252F%255Fcatalogs%252Fwp%252FDisplayListItem%252Edwp;DisplayListItem. Exception System.InvalidOperationException: Beim Generieren des XML-Dokuments ist ein Fehler aufgetreten. —> System.ArgumentException: Der Wert liegt außerhalb des erwarteten Bereichs. bei Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException) bei Microsoft.SharePoint.SPListCollection.get_Item(String strListName) bei RH.DisplayListItem.GetViewName(String _ListName, String _ViewName) bei RH.DisplayListItem.get_ViewName() bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterDisplayListItem.Write11_DisplayListItem(String n, String ns, DisplayListItem o, Boolean isNullable, …

 

Leave a Reply