raklos
raklos

Reputation: 28545

get a guid of an list item of a sharepoint list

Im using SPDataSource to bind a sharepoint list to a repeater control

within the itemtemplate of the repeater i am using things such as

<%# Eval("Title") %>

im trying to get an id for the list item, ideally something like a guid eg

but the above does not work... how can i get a guid? btw i did <%# Eval("ID") %> this worked however it returns a number e.g 1, 2, 3..

ideally i want something more like a guid.

thanks

Upvotes: 2

Views: 6845

Answers (4)

boro.djuka
boro.djuka

Reputation: 108

Ugly, but works

<%# ((SPListItem)((SPDataSourceViewResultItem)Container.DataItem).ResultItem).UniqueId %>

Don't forget to add

<%@ Import Namespace="Microsoft.SharePoint" %>   
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 

Simple way

<%# Eval("UniqueId") %>

works only if you set IncludeHidden to true on your SPDataSource

Upvotes: 3

Rubens Farias
Rubens Farias

Reputation: 57946

Try <%# Eval("UniqueId") %>

Upvotes: 1

Magnus Johansson
Magnus Johansson

Reputation: 28325

The SPListItem property UniqueId is the unique identifier for the item.

So try

<%# Eval("UniqueId") %>

Please note the case sensitivity.

Upvotes: 1

Alex Angas
Alex Angas

Reputation: 60027

The GUID for a list item is stored in SPListItem.UniqueId.

Upvotes: 0

Related Questions