Limiting the Data being displayed in the GridView and Display Tooltip

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ViewState["OrigData"] = e.Row.Cells[0].Text;
                if (e.Row.Cells[0].Text.Length >= 30) //Just change the value of 30 based on your requirements
                {
                    e.Row.Cells[0].Text = e.Row.Cells[0].Text.Substring(0, 30) + “…”;
                    e.Row.Cells[0].ToolTip = ViewState["OrigData"].ToString();
                }
             }
}
Ebook Download
View all
Learn
View all