troubleshooting Question

userfulness indicator Asp.net using Vb Code

Avatar of memecece
memecece asked on
ASPASP.NET
11 Comments1 Solution613 ViewsLast Modified:
I am trying to create a usefulness indicator on a page in asp.net using vb code behind. I have my reviews displaying in repeater control which has paging enabled. I have included two buttons to the end of the repeater one for Yes and the other No. I want to keep a count of how many times yes was clicked for that review and how many times no was clicked. By adding the yes count and no count together I can get the total. I can access the buttons but when I click them nothing happens. Would anyone be able to help? I've been trying to do this for hours and I can't find a solution. Below is the code I have used for both the paging and the attempt for the indicator.

Markup Code:
<asp:Repeater ID="movies" runat="server" onItemCommand="movies_ItemCommand">
        <ItemTemplate>
            <table width="641px">
                <tr>
                    <td>
                        <span style="font-weight:bold;font-size:16px;">
                        <%# Container.DataItem("MovieTitle")%>
                            </span>
                    </td>
                    <td>
                        <span style="float:right;">
                        <asp:Image ID="Image1" runat="server" ImageUrl = '<%# Eval("Total")%>' style="width:80px;height:14px;"/>
                       </span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <hr style="height:1px;border-bottom:none;color:#e3e3e3;"/>
                    </td>
                </tr>
                </table>
            <table width="641px">
                <tr>
                    <td>
                        <asp:Image ID="Image2" runat="server" ImageUrl = '<%# Eval("MovieImageFileName")%>' style="width:180px;height:108px;border:1px solid #e3e3e3;"/>
                    </td>
                    <td style="vertical-align:top;">
                        <%# Container.DataItem("ReviewText")%>
                    </td>
                </tr>
                </table>
            <table width="641px">
                
                <tr>
                    <td>
                      Value for Money:
                    </td>
                    <td>
                        <asp:Image ID="Image3" runat="server" ImageUrl ='<%# Eval("ValueForMoney")%>' style="width:80px;height:14px;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Acting Ability: 
                    </td>
                    <td>
                        <asp:Image ID="Image4" runat="server" ImageUrl ='<%# Eval("ActingAbility")%>' style="width:80px;height:14px;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Special Effects:
                    </td>
                    <td>
                        <asp:Image ID="Image5" runat="server" ImageUrl ='<%# Eval("SpecialEffects")%>' style="width:80px;height:14px;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Plot:
                    </td>
                    <td>
                        <asp:Image ID="Image6" runat="server" ImageUrl ='<%# Eval("Plot")%>' style="width:80px;height:14px;"/>
                    </td>
                </tr>
                </table>
            <table width="441px">
                <tr>
                    <td>
                        Reviewed By:
                    </td>
                    <td>
                        <%# Container.DataItem("Username")%>
                    </td>
                    <td>|</td>
                    <td>
                        <%# Container.DataItem("ReviewDate")%>
                    </td>
                    <td>|</td>
                    <td>
                        <%# Container.DataItem("ReviewerType")%> Review
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        Did you find this review helpful?&nbsp;&nbsp;&nbsp;<asp:Button ID="btnYes" runat="server" Text="Yes" />&nbsp;&nbsp;
                        <asp:Button ID="btnNo" runat="server" Text="No" /><br />
                        <asp:Label ID="lblResults" runat="server" Text="Total"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        <hr style="height:1px;border-bottom:none;color:#e3e3e3;"/>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
    </asp:Repeater>

VB Code Behind
 
Dim total As Integer
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        doPaging()
    End Sub

 Function getTheData() As DataTable
        Dim DS As New DataSet()
        Dim strConnect As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
        Server.MapPath("/App_Data/MovieBoard.accdb"))
        Dim objOleDBAdapter As New OleDbDataAdapter("Select MovieTitle, MovieImageFileName, ReviewText, ValueForMoney, ActingAbility, SpecialEffects, Plot, Total, Username, ReviewDate, ReviewerType From Movies, MovieReviews, MReviewRatings, MReviewTexts, UserDetails, ReviewerType WHERE Movies.MovieID = MovieReviews.MovieID AND MovieReviews.MReviewID = MReviewRatings.MReviewID AND MovieReviews.MReviewID = MReviewTexts.MReviewID AND MovieReviews.UserID = UserDetails.UserID AND MovieReviews.ReviewerTypeID = ReviewerType.ReviewerTypeID AND ReviewerType.ReviewerTypeID = 1", strConnect)
        objOleDBAdapter.Fill(DS, "Movies")

        Return DS.Tables("Movies").Copy
    End Function

Sub doPaging()
        pagedData.DataSource = getTheData().DefaultView
        pagedData.AllowPaging = True
        pagedData.PageSize = 1

        Try
            pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString()
        Catch ex As Exception
            pagedData.CurrentPageIndex = 0
        End Try

        btnPrev.Visible = False
        btnNext.Visible = False

        If Not pagedData.IsFirstPage Then
            btnPrev.PostBackUrl = Request.CurrentExecutionFilePath + _
                                           "?Page=" + CStr(pagedData.CurrentPageIndex - 1)
        End If

        If Not pagedData.IsLastPage Then
            btnNext.PostBackUrl = Request.CurrentExecutionFilePath + _
                                           "?Page=" + CStr(pagedData.CurrentPageIndex + 1)
        End If

        pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " & pagedData.PageCount

        movies.DataSource = pagedData
        movies.DataBind()
    End Sub

Protected Sub movies_ItemCommand(source As Object, e As RepeaterCommandEventArgs) Handles movies.ItemCommand
        Dim yCount As Integer
        yCount = 0
        Dim nCount As Integer
        nCount = 0
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
        ListItemType.AlternatingItem Then
            Dim btnYes As Button = CType(e.Item.FindControl("btnYes"), Button)
            Dim btnNo As Button = CType(e.Item.FindControl("btnNo"), Button)
            Dim lblResults As Label = CType(e.Item.FindControl("lblResults"), Label)
            Dim sArgument As String = CType(e.Item.DataItem, 
                     DataRowView).Row.Item("MovieTitle").ToString
            If btnYes.OnClientClick Then
                yCount = yCount + 1
                MsgBox(yCount)
                lblResults.Text = yCount
            ElseIf btnNo.OnClientClick Then
                nCount = nCount + 1
            End If
            total = yCount + nCount

        End If
        MsgBox(total)
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros