2011-03-30 65 views

回答

-1

以下是从列表获得项目的方法,并在web部件中显示它们。它使用一个简单的Label控件,但你可以格式化你喜欢的任何方式:

 Dim SPListVar As SPList 'SharePoint List 

    Dim SPColl As SPListItemCollection 'Define a list item Collection 
    Using Site1 As New SPSite(Me.Context.Request.Url.ToString) 'Define the site 
     Using Web1 As SPWeb = Site1.OpenWeb 'Define the web 
      SPListVar = Web1.Lists("Tasks") 'Point to the required list 
     End Using 
    End Using 

    SPColl = SPListVar.GetItems() ' Fill the List item collection with the return data 

    Dim i As Integer 

    While i < SPColl.Count 

     LblRes.Text = LblRes.Text + SPColl.Item(i).Item("Title").ToString + "<BR>" 

     'Read every record and put it in a new line in the Label control 

     i = i + 1 

    End While 
+0

大,但这与Sharepoint评分有什么关系? – emzero 2011-03-31 19:25:09

+0

评分只是列表项目列。 – Kolten 2011-03-31 20:36:11

+2

是啊,谢谢,但是如何从代码中获得ListItem形状的评分?无处。 – emzero 2011-04-05 20:21:18

0

您可以将SPService获取评级的网址:

 //Get Rating on Url 
     //libraryUrl is url of your library 
     $().SPServices({ 
      operation: "GetRatingOnUrl", 
      url: libraryUrl, 
      async: false, 
      completefunc: function (xData, Status) { 
       if (Status == "success") { 
        var url = $(xData.responseXML).find("Url").text(); 
        var rating = $(xData.responseXML).find("Rating").text(); 
        var user = $(xData.responseXML).find("Owner").text(); 
        .... 
       } 
      } 
     }); 

当Web服务返回XML,然后你可以得到你需要想一些信息:URL,所有者,最后修改时间,标题和评级

相关问题