1. 程式人生 > >修復Gridview中字串過長的問題

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