Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 栅格视图列中的有限大小(截断字符串长度)_C#_Asp.net_Gridview - Fatal编程技术网

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; 
}