Click here to Skip to main content
15,889,487 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want to show data from database on mouseover of gridview row.i want to call a function by passing some parameters to a function which will return some rows from databse and display those rows in a tabular format on tool tip of gridview . How can i do this?
Posted

 
Share this answer
 
Comments
pwavell 1-Apr-14 2:56am    
Thanks for the link but i need to call a function on mouseover accepting some params and returning multiple rows and then display that rows as tooltip.
try this in aspx page,

Tooltip='<%# Eval("tooltipField")%>'
 
Share this answer
 
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.Header)
       {
           for (int i = 0; i < GridView1.Columns.Count; i++)
           {
               e.Row.Cells[i].ToolTip = GridView1.Columns[i].HeaderText;
           }

       }
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           foreach (TableCell gvcell in e.Row.Cells)
           {
               gvcell.ToolTip = gvcell.Text;

           }


       }
   }
 
Share this answer
 
XML
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            DataSourceID="SqlDataSource1" AutoGenerateColumns="false">
            <Columns>

                <asp:TemplateField>
                    <HeaderTemplate>
                        Region
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbl" runat="server" Text='<%# Eval("name") %>' ToolTip='<%# Eval("empcode") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:yourDBConnectionString %>"
            SelectCommand="SELECT * FROM tab1">
        </asp:SqlDataSource>
 
Share this answer
 
v5

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