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

RadToolTip Not Shown all Buttons in GridView

4 Answers 228 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Cancer
Top achievements
Rank 1
Cancer asked on 09 May 2007, 04:50 AM
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?  

4 Answers, 1 is accepted

Sort by
0
surfer
Top achievements
Rank 1
answered on 09 May 2007, 10:22 AM
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.
0
Cancer
Top achievements
Rank 1
answered on 10 May 2007, 04:22 AM

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

0
Johan
Top achievements
Rank 1
answered on 10 May 2007, 05:16 AM
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 

0
Carry
Top achievements
Rank 1
answered on 10 May 2007, 07:18 AM
Thanks alot....finally my Problem got solve....now i can watch ToolTip on all buttons of Grid 
Tags
ToolTip
Asked by
Cancer
Top achievements
Rank 1
Answers by
surfer
Top achievements
Rank 1
Cancer
Top achievements
Rank 1
Johan
Top achievements
Rank 1
Carry
Top achievements
Rank 1
Share this question
or