How to bind tooltip on datagrid rows?
I'm trying to bind datagrid rows with tooltip. In which event should i write the code? The row created event doesnt hold my data to bind and returning blank. The code reference is given below:
protected void gdvAct开发者_运维技巧ionItemView_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].ToolTip = e.Row.Cells[2].Text;
if (e.Row.Cells[2].Text.Length > 100)
{
e.Row.Cells[2].Text.Substring(0, 100);
}
}
Please help.
You can right Row Databound event such as:
protected void grdUserClone_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int colIndex = 0; colIndex < e.Row.Cells.Count; colIndex++)
{
e.Row.Cells[colIndex].Attributes.Add("title", e.Row.Cells[colIndex].Text);
}
}
}
Found the answer. It should be written under RowDataBound.
精彩评论