[英]How to bind tooltip on datagrid rows?
我正在嘗試使用工具提示綁定datagrid行。 在哪種情況下我應該編寫代碼? 創建行的事件未保存要綁定的數據,並返回空白。 代碼參考如下:
protected void gdvActionItemView_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);
}
}
請幫忙。
您可以糾正行數據綁定事件,例如:
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);
}
}
}
找到了答案。 它應該寫在RowDataBound下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.