修复Gridview中字符串过长的问题

  /// <summary> 
    /// 修复单元格中字符串过长的问题
    /// 同时给单元格添加鼠标悬停事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string tx= e.Row.Cells[8].Text;
            e.Row.Cells[8].ToolTip = tx;
            if (tx.Length > 10)
            {
                tx = tx.Substring(0, 10) + "......";
            }
            e.Row.Cells[8].Text = tx;
        }

猜你喜欢

转载自blog.csdn.net/lxuabcd/article/details/50446523