Yes, you need to do that in GridView RowDatabound:
C#:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// get a refernce to the label
Label lbl = e.Row.FindControl("Label1") as Label;
if (lbl.Text.Length > 50)
{
string tooltip = lbl.Text;
string lblText = lbl.Text.Substring(0, 50) + "...";
lbl.ToolTip = tooltip;
lbl.Text = lblText;
}
else
{
lbl.ToolTip = lbl.Text;
}
}
}
VB:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
' get a refernce to the label
Dim lbl As Label = TryCast(e.Row.FindControl("Label1"), Label)
If lbl.Text.Length > 50 Then
Dim tooltip As String = lbl.Text
Dim lblText As String = lbl.Text.Substring(0, 50) + "..."
lbl.ToolTip = tooltip
lbl.Text = lblText
Else
lbl.ToolTip = lbl.Text
End If
End If
End Sub