在GridView1_RowDataBound事件中
If e.Row.Cells(4).Text.Length > 10 Then
e.Row.Cells(4).Text = Left(e.Row.Cells(4).Text, 10) & "..."
End If
这里只是对一行中的某一列进行截取
如果是对全部的列进行截取,则在外面用for,并且用title实现鼠标指向单元格显示完整字符串
For i As Int32 = 0 To e.Row.Cells.Count - 1标签:10,Text,Cells,单元格,当鼠标,字符串,截取,Row From: https://blog.51cto.com/u_21817/6066503
tempTitle = e.Row.Cells(i).Text
If e.Row.Cells(i).Text.Length > 10 Then
e.Row.Cells(i).Text = Left(e.Row.Cells(i).Text, 10) & "..."
End If
e.Row.Cells(i).Attributes.Add("title", tempTitle)
Next