Sunday, June 19, 2011

To control excess data to display in gridview cell



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow)
{
ViewState["Data"] = e.Row.Cells[1].Text;
if (e.Row.Cells[1].Text.Length > 25)
{
e.Row.Cells[1].Text = e.Row.Cells[1].Text.Substring(0, 25) + “…”;
e.Row.Cells[1].ToolTip = ViewState["Data"].ToString();
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More