Show gridview control cell value in tooptip on mouseover

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="error_log_id,inner_error_id"DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." OnRowDataBound="GridView1_RowDataBound" BackColor="#DEBA84" BorderColor="#DEBA84"
CellPadding="3" CellSpacing="2" BorderWidth="2" BorderStyle="Solid">
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" BorderWidth="2" BorderStyle="Solid" />
   <Columns>
    <asp:TemplateField HeaderText="Date">
        <ItemTemplate>
            <asp:Label runat="server" ID="lbldate" Text='<%# DataBinder.Eval(Container.DataItem,"date") %>'
                   Width="150" Height="25"></asp:Label>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Message">
        <ItemTemplate>
            <asp:Label runat="server" ID="lblmessage" Text='<%# DataBinder.Eval(Container.DataItem,"message") %>'
                   Width="150" Height="25"></asp:Label>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Source">
        <ItemTemplate>
            <asp:Label runat="server" ID="lblsource" Text='<%# DataBinder.Eval(Container.DataItem,"source") %>'
                   Width="150" Height="25"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    <asp:TemplateField HeaderText="Detail">
        <ItemTemplate>
            <asp:Label runat="server" ID="lbldetail" Text='<%# DataBinder.Eval(Container.DataItem,"detail") %>'
                   Width="150" Height="25"></asp:Label>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Stack">
        <ItemTemplate>
            <asp:TextBox runat="server" ID="lblStack" Text='<%# DataBinder.Eval(Container.DataItem,"stack") %>'
                     Width="100" TextMode="MultiLine" Wrap="true" ReadOnly="true" BorderStyle="Outset"                          Height="150"></asp:TextBox>   
        </ItemTemplate>
    </asp:TemplateField>
    </Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>

C#


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        Label lbldate = (Label)e.Row.FindControl("lbldate");
        lbldate.ToolTip = lbldate.Text;
        Label lblmessage = (Label)e.Row.FindControl("lblmessage");
        lblmessage.ToolTip = lblmessage.Text;
        Label lblsource = (Label)e.Row.FindControl("lblsource");
        lblsource.ToolTip = lblsource.Text;
        TextBox lblStack = (TextBox)e.Row.FindControl("lblStack");
        lblStack.ToolTip = lblStack.Text;
    }
}

VB.Net


Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim lbldate As Label = DirectCast(e.Row.FindControl("lbldate"), Label)
        lbldate.ToolTip = lbldate.Text
        Dim lblmessage As Label = DirectCast(e.Row.FindControl("lblmessage"), Label)
        lblmessage.ToolTip = lblmessage.Text
        Dim lblsource As Label = DirectCast(e.Row.FindControl("lblsource"), Label)
        lblsource.ToolTip = lblsource.Text
        Dim lblStack As TextBox = DirectCast(e.Row.FindControl("lblStack"), TextBox)
        lblStack.ToolTip = lblStack.Text
    End If
End Sub

Ebook Download
View all
Learn
View all