最简单的可以通过CSS来设置省略号,
鼠标移上全部显示用ToolTip,
1.CSS:
<style type="text/css">
.mlength
{
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}
</style>
2.设置GeidView某一字段为模板列并设置css,如:
<asp:Label ID="Label1" runat="server" Text='<%# Eval("字段") %>' CssClass="mlength"></asp:Label>
3.后台设置tooltip:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Label)e.Row.Cells[0].FindControl("Label1")).ToolTip = ((Label)e.Row.Cells[0].FindControl("Label1")).Text;
}
}
鼠标移上全部显示用ToolTip,
1.CSS:
<style type="text/css">
.mlength
{
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}
</style>
2.设置GeidView某一字段为模板列并设置css,如:
<asp:Label ID="Label1" runat="server" Text='<%# Eval("字段") %>' CssClass="mlength"></asp:Label>
3.后台设置tooltip:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Label)e.Row.Cells[0].FindControl("Label1")).ToolTip = ((Label)e.Row.Cells[0].FindControl("Label1")).Text;
}
}