鼠标移动到gridVIew某列中显示此列的详细内容

在gridView列表中,有的时候某列中的内容过多,我们只显示之前的部分,查看详细后才能知道全部内容,

这几天有个需求:鼠标移动到此列需要显示全部信息,方法如下:

 //如果说明字数过多则显示概要
    protected void gvInitAcceptList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[3].Text.Length > 40)
            {
                e.Row.Cells[3].Text = e.Row.Cells[3].Text.Substring(0, 40) + "...";
            }
        }
    } 

 

//鼠标指到此列时会显示此列的详细信息

protected void gvSpot_RowDataBound(object sender, GridViewRowEventArgs e)
    {
         if (e.Row.RowType == DataControlRowType.DataRow)
        {

           string note = e.Row.Cells[12].Text.ToString();
            if (note != "" && note != " ")
            {
                //鼠标移到此列 显示此列的信息

                e.Row.Cells[12].ToolTip = note;
                e.Row.Cells[12].Attributes["style"] = "Cursor:hand";
            }
        }
    }

posted @ 2012-11-26 14:16  Mr zhao  阅读(281)  评论(0编辑  收藏  举报