2013-02-19 52 views
2
<asp:ListView ID="ListView1" runat="server"> 
       <LayoutTemplate> 
         <asp:PlaceHolder runat="server" ID="itemplaceholder"></asp:PlaceHolder> 
       </LayoutTemplate> 

       <ItemTemplate> 
          <sc:Image runat="server" ID="ImageRenderer1" Field="ThumbImage" 
          Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" />  

          <sc:FieldRenderer ID="FieldRenderer2" runat="server" FieldName="Headline" 
          Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" /><br /> 
      </ItemTemplate> 
      </asp:ListView> 

後面的代碼項目的綁定鏈接:Sitecore的:

string path = "/abc/abc/abc/abc/abc/abc/abc/abc/abc/abc"; 
var item = sc.Context.Database.GetItem(path); 
MultilistField m = item.Fields["test"]; 
Item[] collection = m.GetItems(); 
ListView1.DataSource = dataset; 
ListView1.DataBind(); 

在MultilistField,男,它將獲得至少10個項目。現在,我需要爲用戶點擊鏈接的標題字段創建鏈接,它會將用戶重定向到該特定項目。任何想法 ?

回答

2

使用Sitecore的LinkManager類來獲得這樣的鏈接:

<a href="<%# Sitecore.Links.LinkManager.GetItemUrl(Container.DataItem as Sitecore.Data.Items.Item) %>"> 
    headline code here 
</a> 
+0

感謝,從來沒有想過的吧..〜 – WenHao 2013-02-19 08:59:00