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
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)
{
if (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
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 |