C# 栅格视图列中的有限大小(截断字符串长度)
这是我的网格视图编码,我想菜单名截断长度为基础。C# 栅格视图列中的有限大小(截断字符串长度),c#,asp.net,gridview,C#,Asp.net,Gridview,这是我的网格视图编码,我想菜单名截断长度为基础。 现在我需要基于truncateLenth的列。为什么不给您的单元格一个css类,并将文本溢出属性设置为省略号 .cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } if (e.Row.RowType == DataControlRowType.DataRow) {
现在我需要基于truncateLenth的列。为什么不给您的单元格一个css类,并将文本溢出属性设置为省略号
.cell {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell cell in e.Row.Cells)
{
i++;
string Word = cell.Text;
if (cell.Text.Length > 5 && (i == 1))
cell.Text = cell.Text.Substring(0, 5) + "....";
if (cell.Text.Length > 3 && (i == 3))
cell.Text = cell.Text.Substring(0, 3) + "....";
if (cell.Text.Length > 6 && (i == 2))
cell.Text = cell.Text.Substring(0, 6) + "....";
cell.ToolTip = Word;
}
}
}
.cell {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}