RadToolTip Not Shown all Buttons in GridView

5 posts, 0 answers
  1. Cancer
    Cancer avatar
    6 posts
    Member since:
    May 2007

    Posted 08 May 2007 Link to this post

    Hi
    I have a Gridview. There is one column which is of templateField Type. on this templatefiled's  ItemTemplate there I placed <asp:button>

    I have used tooltip this button

    <telerik:RadToolTip ID="RadToolTip_ForGrid" runat="server" TargetControlID="btnAdd" Text="Add Button with in Grid" Width="150" Sticky="true"></telerik:RadToolTip>

    But the problem is that this tooltip is shown on MouseOver for only FirstButton in Column. For Rest of buttons in same column no tooltip shown...How ToolTip can  be displayed for all buttons?  

  2. surfer
    surfer avatar
    585 posts
    Member since:
    Jul 2003

    Posted 09 May 2007 Link to this post

    You may need to hook the GridView ItemCreated event, find the button in the template using FindControl and add the tooltip for each button programmatically, using the ClientID of the button for TargetControlID and by setting the IsClientID property of the ToolTip instance to True.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cancer
    Cancer avatar
    6 posts
    Member since:
    May 2007

    Posted 09 May 2007 Link to this post

    Hi
    I have done the following coding on GridView's ItemCreated Event

    GridBind()
    {
    String[] A1 = new String[4];
    A1[0] =
    "AAA";
    A1[1] =
    "BBB";
    A1[2] =
    "CCC";
    A1[3] =
    "DDD";
    GridView1.DataSource = A1;
    GridView1.DataBind();

    }
    protected
    void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType ==DataControlRowType.DataRow)
    {
    i
    f (e.Row.DataItem != null)
    {
    if (e.Row.DataItemIndex==0)
    {
    System.Web.UI.WebControls.
    Button b1 = (System.Web.UI.WebControls.Button)e.Row.FindControl("btnAdd");
    DataRowView curRow = (DataRowView)e.Row.DataItem;
    b1.ID = curRow.Row[
    "ID"].ToString();
    this.RadToolTipManager1.TargetControls.Add(b1.ClientID, true);
    }
    }
    }
    }
    protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)
    {
    e.UpdatePanel.ContentTemplateContainer.Controls.Add(
    new HtmlGenericControl("HR"));
    }

    <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated">
    <Columns>
    <asp:TemplateField HeaderText="Add">
    <ItemTemplate>
    <asp:Button ID="btnAdd" runat="server" Text="ADD" /></ItemTemplate></asp:TemplateField></Columns></asp:GridView>

    But am getting Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'.  Error. In my Grid view there two colums one is Template Column for Button and other is autogenerated Column displays the items.

    Thanks In Advance
    Cancer

  5. Johan
    Johan avatar
    617 posts
    Member since:
    Mar 2007

    Posted 10 May 2007 Link to this post

    The problem is the following line:

    DataRowView curRow = (DataRowView)e.Row.DataItem;

    You are casting to DataRowView, which is a row in DataTable, while you are binding to string. You can create fake test DataTable using something similar to:

    Private Function CreateTestTable() As DataTable 
            Dim table As New DataTable 
     
            table.Columns.Add("Name"
            table.Columns.Add("OnSiteID"
     
            table.Rows.Add(New Object() {"Item1""Value1"}) 
            table.Rows.Add(New Object() {"Item2""Value2"}) 
            table.Rows.Add(New Object() {"Item3""Value3"}) 
     
            Return table 
        End Function 'CreateTestTable 

  6. Carry
    Carry avatar
    20 posts
    Member since:
    Apr 2007

    Posted 10 May 2007 Link to this post

    Thanks alot....finally my Problem got solve....now i can watch ToolTip on all buttons of Grid 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017