Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How to add tool tip for gridview cells and how to add styles for that tool tip....
Posted

Try This :

<asp:gridview id="GridView1" runat="server">

 <columns>

  <asp:templatefield headertext="Title">
       
       <itemtemplate>

           <asp:linkbutton id="link1" runat="server" commandname="link" forecolor="Blue" tooltip="<%# String.Format("your String  :{0}", Eval("field_name from db for tooltip"))%>"> <%#Eval("filed")%></asp:linkbutton>
       </itemtemplate>     
          
      <itemstyle forecolor="Blue" font-size="Medium" />
          
       </asp:templatefield>
      
       
       </columns>



</asp:gridview>

this will help you for your problem. you must bind the grid first.


If not, please post it.


Mitesh
 
Share this answer
 
v2
Its very simple. On row data event You can add tooltip to a Cell.


Step1: Create a new Application:

Add a page name: gridTooltip

Step2: Add the following code inside the gridTooltip.aspx page:
ASP
<asp:gridview id="GridView1" runat="server" onrowdatabound="GridView1_RowDataBound" xmlns:asp="#unknown">
        </asp:gridview>


Step3: Inside gridTooltip.aspx.cs page add the following code:
C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           BindGrid();
       }
   }
   public class Data
   {
       public string Name
       {
           get;
           set;
       }
       public int Age
       {
           get;
           set;
       }
   }

   public void BindGrid()
   {
       Data obj = new Data();
       obj.Name = "Kabir";
       obj.Age = 28;

       Data obj1 = new Data();
       obj1.Name = "Safiul";
       obj1.Age = 28;

       List<Data> olist = new List<Data>();
       olist.Add(obj);
       olist.Add(obj1);

       GridView1.DataSource = olist;
       GridView1.DataBind();
   }

   protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           e.Row.Cells[0].ToolTip = "My Name is: " + e.Row.Cells[0].Text;
           e.Row.Cells[1].ToolTip = "My age is: " + e.Row.Cells[1].Text;
       }
   }



---- Now run the application.
--- Hope it will help you

[Edit]Code blocks added[/Edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900