This is a migrated thread and some comments may be shown as answers.

Problem with loading tool tip in repeater

1 Answer 109 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 06 Jun 2012, 06:23 PM
I'm trying to fix a site I didn't build and I can't figure out why this data is not binding. It's a tool tip inside of a repeater and the tool tip has a control in it. Here is the code.

<telerik:RadToolTip ID="PaperRevTooltip" runat="server" ManualClose="True" Modal="True"
            Position="Center" RelativeTo="BrowserWindow" ShowEvent="FromCode" Skin="Telerik"
            Title="Reviewers" Width="400" Height="400">
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table border="0" cellpadding="0" cellspacing="5">
                </HeaderTemplate>
                <ItemTemplate>
                    <UC1:UControl ID="test3" runat="server" PaperID='<%# DataBinder.Eval(Container.DataItem, "PaperID")%>'
                        ReviewerID='<%# DataBinder.Eval(Container.DataItem, "ReviewerUserID")%>' reviewId='<%# DataBinder.Eval(Container.DataItem, "ReviewOfPaperID")%>' />
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:SqlDataSource ID="ReviewersSqlDS" runat="server" ConnectionString="<%$ ConnectionStrings:conferencehubConnectionString %>"
                SelectCommand="admin_PaperReviewers" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:Parameter Name="PaperID" Type="Int16" DefaultValue="0" Direction="Input" />
                </SelectParameters>
            </asp:SqlDataSource>
        </telerik:RadToolTip>

Here is the relevant code behind for that page. note the item command comes from a rad grid the tool tip shows, but with nothing but the title
Protected Sub item_command(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles PapersGV.ItemCommand
       Dim index As Integer
       Dim paperID As String
       If e.CommandName = "changeRev" Then
           index = e.Item.ItemIndex
           paperID = Me.PapersGV.Items(index).GetDataKeyValue("PaperID")
           Me.PaperRevTooltip.Title = Me.PapersGV.Items(index).GetDataKeyValue("PaperTitle")
 
           loadPaperReviewersData(paperID)
 
           Me.PaperRevTooltip.visible = True
           Me.PaperRevTooltip.Show()
       Else
           Me.PaperRevTooltip.visible = False
       End If
   End Sub
Protected Sub loadPaperReviewersData(ByVal paperID As String)
       Dim dt As DataTable
       Dim connString As String = System.Configuration.ConfigurationManager.ConnectionStrings("conferencehubConnectionString").ToString
       Dim myConnection As New Data.SqlClient.SqlConnection(connString)
       Dim strSQL As String = "admin_PaperReviewers"
       Dim selectCommand As New Data.SqlClient.SqlCommand(strSQL, myConnection)
       Dim SQLReader As SqlDataReader
       Dim paperIDParam As SqlParameter
       Dim values() = {"-1", "-1", "0", paperID, ""}
       Try
           selectCommand.CommandType = Data.CommandType.StoredProcedure
           paperIDParam = New SqlParameter("PaperId", Data.SqlDbType.Int)
           paperIDParam.Value = paperID
           selectCommand.Parameters.Add(paperIDParam)
           myConnection.Open()
           SQLReader = selectCommand.ExecuteReader()
           dt = New DataTable
           dt.Load(SQLReader)
           myConnection.Close()
 
           'While dt.Rows.Count < minReviewers
           If dt.Rows.Count < maxReviewers Then
               dt.Rows.Add(values)
           End If
 
           'End While
 
           Me.paperReviewersDT = dt
           Me.Repeater1.DataSource = dt
           Me.Repeater1.DataBind()
       Catch ex As Exception
           Response.Write("There has been an error.<br />" & ex.ToString & "<Br />" & strSQL)
       Finally
           myConnection.Close()
       End Try
   End Sub
   Private Property paperReviewersDT() As DataTable
       Get
           Return CType(ViewState("allRevs"), DataTable)
       End Get
       Set(ByVal value As DataTable)
           ViewState("allRevs") = value
       End Set
   End Property


Here is the control uc1
    <td>test
        <asp:Label ID="output" runat="server"></asp:Label>
        <asp:DropDownList ID="RevDropDownList" runat="server" DataSourceID="TrackSqlDS" DataTextField="ReviewerName"
            DataValueField="UserID">
        </asp:DropDownList>
        <asp:CustomValidator ID="revValidator" runat="server" ErrorMessage="*"></asp:CustomValidator>
    </td>
    <td>
        <asp:Button ID="AddButton" runat="server" Text="Add" CommandName="AddReviewer" />
     
        <asp:Button ID="DelButton" runat="server" Text="Delete" CommandName="DeleteReviewer"
            Visible="false" />
     
        <asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="UpdateReviewer"
            Visible="false"/>
    </td>
    <asp:SqlDataSource ID="TrackSqlDS" runat="server" ConnectionString="<%$ ConnectionStrings:conferencehubConnectionString %>"
        SelectCommand="admin_AllReviewers" SelectCommandType="StoredProcedure" OnSelecting="TrackItDataSource_Selecting">
        <SelectParameters>
            <asp:Parameter Name="PaperID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</tr>

And the control code
    Private _ReviewerID As Integer
    Private _ReviewID As Integer
    Public Property reviewId() As Integer
        Get
            Return CType(ViewState("reviewId"), Integer)
        End Get
        Set(ByVal value As Integer)
            ViewState("reviewId") = value
        End Set
    End Property
 
    Public Property PaperID() As Integer
        Get
            Return CType(ViewState("paperId"), Integer)
        End Get
        Set(ByVal value As Integer)
            ViewState("paperId") = value
        End Set
    End Property
    Public Property ReviewerID() As Integer
        Get
            Return Me.RevDropDownList.SelectedItem.Value
        End Get
        Set(ByVal value As Integer)
            _ReviewerID = value
        End Set
    End Property
    Public ReadOnly Property ReviewerName() As String
        Get
            Return Me.RevDropDownList.SelectedItem.Text
        End Get
    End Property
#Region "SQLDS Events"
    Protected Sub TrackItDataSource_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceSelectingEventArgs)
        e.Command.Parameters.Item(0).Value = PaperID
    End Sub
#End Region
    Protected Sub rev_Bound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RevDropDownList.DataBound
        Dim defaultItem As New ListItem("- Select Reviewer -", "-1")
        RevDropDownList.Items.Insert(0, defaultItem)
        output.Text = "test"
        If _ReviewerID <> 0 Then
            RevDropDownList.Items.FindByValue(_ReviewerID).Selected = True
        End If
 
        If isValid() Then
            AddButton.Visible = False
            UpdateButton.Visible = True
            DelButton.Visible = True
        End If
    End Sub
    Public Function isValid() As Boolean
        If RevDropDownList.SelectedIndex = 0 Then
            revValidator.IsValid = False
            Return False
        Else
            Return True
        End If
    End Function
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RevDropDownList.DataBind()
        output.Text = "test"
    End Sub
    Protected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click
        If isValid() Then
            ReviewerID = Me.RevDropDownList.SelectedItem.Value
        End If
    End Sub

I'm kind of lost as to why not even the text "test" shows up when you show the tool tip.









1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 08 Jun 2012, 11:27 AM
Hello,

This stems from the fact that the Page_Load of the user control is fired too early in the page lifecycle for your needs and the repeater is still not databound. You would have the same issue when you replace the RadTooltip with a simple asp Panel. Nevertheless I am attaching here the modified pages that seem to work correctly with me - note the difference is only that I am using the Page_PreRender event in the user control and that I replaced your datasources with a programmatic datatable for clarity. I also changed the property fields to Strings, but this is not relevant to the case.

Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ToolTip
Asked by
Web Services
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or