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

grid that has a tooltip

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patricia Byrne
Top achievements
Rank 1
Patricia Byrne asked on 19 Jul 2010, 05:44 PM
I think what I'm asking is very basic but I can't figure out what I'm doing wrong.

I have a grid with a tooltip. I'm using the demo for the grid and tried to adjust it to work with my database. It's in vb. I'm getting the following error when I hover over a link that has the tooltip.:

Object references not set to an instance of an object. Thank you for any help.

asp.x page:
<%@ Register Src="ProductDetails.ascx" TagName="ProductDetails" TagPrefix="uc1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
    <link rel="Stylesheet" href="StyleSheet.css" />
</head>
<body class="BODY">
    <form id="Form1" method="post" runat="server">
    
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
       
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
        Width="250" Height="350" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"
        Position="MiddleRight">
    </telerik:RadToolTipManager>
    <telerik:RadGrid ID="RadGrid1" Width="550" runat="server" DataSourceID="SqlDataSource1"
        GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" AllowPaging="true"
        AllowSorting="true" PageSize="10" OnItemCommand="RadGrid1_ItemCommand">
        <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst"
            DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" Dir="LTR" Frame="Border"
            TableLayout="Auto">
            <Columns>
                <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="CustomerID" Display="false"
                    DataType="System.Int32" FilterListOptions="VaryByDataType" ForceExtractValue="None"
                    HeaderText="ProductID" ReadOnly="True" SortExpression="CustomerID" UniqueName="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="Applicant" SortExpression="Applicant">
                    <ItemTemplate>
                        <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("Applicant") %>'></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn AllowSorting="true" DataField="CompanyName" HeaderText="Supplier"
                    SortExpression="CompanyName" UniqueName="CompanyName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn AllowSorting="true" DataField="UnitPrice" DataFormatString="{0:C}"
                    HeaderText="Price" SortExpression="UnitPrice">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:BureauConnectionString %>"
            SelectCommand="SELECT * FROM [bureauSummary]"></asp:SqlDataSource>
    
    </form>

vb code behind code:
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Imports Telerik.Web.UI

Imports System.IO

Namespace Telerik.Web.Examples.ToolTip.TargetControlsAndAjax
    Partial Public Class DefaultVB
        Inherits System.Web.UI.Page
        Protected Sub OnAjaxUpdate(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs)
            Me.UpdateToolTip(args.Value, args.UpdatePanel)
        End Sub
        Private Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)
            Dim ctrl As Control = Page.LoadControl("ProductDetails.ascx")
            panel.ContentTemplateContainer.Controls.Add(ctrl)
            Dim details As ProductDetails = DirectCast(ctrl, ProductDetails)
            details.ProductID = elementID
        End Sub
        Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
            If e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then
                Dim target As Control = e.Item.FindControl("targetControl")
                If Not [Object].Equals(target, Nothing) Then
                    If Not [Object].Equals(Me.RadToolTipManager1, Nothing) Then
                        'Add the button (target) id to the tooltip manager

                        Me.RadToolTipManager1.TargetControls.Add(target.ClientID, (TryCast(e.Item, GridDataItem)).GetDataKeyValue("CustomerID").ToString(), True)
                    End If
                End If
            End If
        End Sub
        Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
            If e.CommandName = "Sort" OrElse e.CommandName = "Page" Then
                RadToolTipManager1.TargetControls.Clear()
            End If

        End Sub
    End Class
End Namespace


ProductDetails.ascx  code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductDetails.ascx.cs"
    Inherits="Telerik.Web.Examples.ToolTip.TargetControlsAndAjax.ProductDetails" %>

<table runat="server" style="width: 100%" id="ProductWrapper" border="0" cellpadding="2"
    cellspacing="0">
    <tr>
        <td style="text-align: center;">
            <asp:FormView ID="ProductsView" DataSourceID="ProductDataSource" DataKeyNames="CustomerID"
                runat="server" OnDataBound="ProductsView_DataBound">       
               
                <ItemTemplate>
                    <asp:Label CssClass="title" ID="Category" runat="server"><%# Eval("CoApplicant")%></asp:Label>
                    <hr />
                    <span class='title'>Equifax:</span>
                    <asp:Label CssClass="info" ID="Label1" runat="server"><%# Eval("Equifax")%></asp:Label>
                    <br />
                    <span class='title'>Experian:</span>
                    <asp:Label CssClass="info" ID="Label2" runat="server"><%# Eval("Experian")%></asp:Label>
                    <br />
                    <span class='title'>ID/OFAC:</span>
                    <asp:Label CssClass="info" ID="Label3" runat="server"><%# Eval("IDOFACText")%></asp:Label>
                    <br />
                </ItemTemplate>
            </asp:FormView>
        </td>
    </tr>
</table>

<asp:SqlDataSource ID="ProductDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:BureauConnectionString %>"
    SelectCommand="SELECT * FROM [bureauSummary] WHERE ([CustomerID] = @CustomerID)">
    <SelectParameters>
        <asp:Parameter Name="CustomerID" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

ProductDetails.ascx  code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.IO;


namespace Telerik.Web.Examples.ToolTip.TargetControlsAndAjax
{

    public partial class ProductDetails : System.Web.UI.UserControl
    {

        public string ProductID
        {
            get
            {
                if (ViewState["CustomerID"] == null)
                {
                    return "";
                }
                return (string)ViewState["CustomerID"];
            }
            set
            {
               
                ViewState["CustomerID"] = value;
            
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            this.ProductDataSource.SelectParameters["CustomerID"].DefaultValue = this.ProductID;

            this.DataBind();
        }


        

    }
}




2 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 22 Jul 2010, 11:57 AM
Hello Patricia,

I have reviewed your code and I was not able to find any mistakes in it.
If the issue persists, please open a formal support ticket and send us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.

Thank you in advance for the cooperation.

Regards,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Patricia Byrne
Top achievements
Rank 1
answered on 22 Jul 2010, 01:39 PM
Hi,

Thank you for your reply. I will setup a support ticket.

Patricia
Tags
Grid
Asked by
Patricia Byrne
Top achievements
Rank 1
Answers by
Mira
Telerik team
Patricia Byrne
Top achievements
Rank 1
Share this question
or