我不确定是否有办法做到这一点。我试图计算每部电影的星级评分总数。我可以获得所有电影评论的总数5,4,3,2,1星评级。我遇到麻烦但是只获得特定页面上每部电影的5,4,3,2,1评级总数。我的评论显示在转发器中,因此在每个页面上我希望获得该特定电影获得的5星评级的总数等等。
以下是我到目前为止的代码片段:
Function getTheData4() As DataTable
Dim DS4 As New DataSet()
Dim strConnect4 As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
Server.MapPath("/App_Data/MovieBoard.accdb"))
Dim objOleDBAdapter4 As New OleDbDataAdapter("SELECT COUNT(Total) AS TotalRating2, MovieReviews.MReviewID FROM MReviewRatings, MovieReviews, Movies, ReviewerType WHERE MReviewRatings.MReviewID = MovieReviews.MReviewID AND MovieReviews.MovieID = Movies.MovieID AND MovieReviews.ReviewerTypeID = ReviewerType.ReviewerTypeID AND Total = '../images/stars/4Star.png' AND MovieReviews.ReviewerTypeID = 2 GROUP BY MovieReviews.MReviewID, MovieTitle;", strConnect4)
objOleDBAdapter4.Fill(DS4, "MReviewRatings")
Return DS4.Tables("MReviewRatings").Copy
End Function
这就是使用getTheData4()的方法:
Sub doPaging4()
pagedData4.DataSource = getTheData4().DefaultView
pagedData4.AllowPaging = True
pagedData4.PageSize = 1
Try
pagedData4.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString()
Catch ex As Exception
pagedData4.CurrentPageIndex = 0
End Try
btnPrev4.Visible = False
btnNext4.Visible = False
If Not pagedData4.IsFirstPage Then
btnPrev4.PostBackUrl = Request.CurrentExecutionFilePath + _
"?Page=" + CStr(pagedData4.CurrentPageIndex - 1)
End If
If Not pagedData4.IsLastPage Then
btnNext4.PostBackUrl = Request.CurrentExecutionFilePath + _
"?Page=" + CStr(pagedData4.CurrentPageIndex + 1)
End If
pageNumber4.Text = (pagedData4.CurrentPageIndex + 1) & " of " & pagedData4.PageCount
fourStars.DataSource = pagedData4
fourStars.DataBind()
End Sub
有没有办法将它连接到我的转发器控件,这样当转发器控制页面时,这里的信息也会改变?例如,在第1页,正在审查的电影是霍比特人。这个共5个星评分可能是5,4星将是3,等等,然后第2页上所评论的电影将是Pi的生活和收视率将变为例如5星评级将是3,4星级会是2等?
对asp来说真的很新,所以不知道我试图做什么就可以了。