Loading ...

Table Text Is Wrapping

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  client side web development   » Table Text Is Wrapping

Table Text Is Wrapping

Posts under the topic: Table Text Is Wrapping

Posted: 8/13/2011

Lurker 160  points  Lurker
  • Joined on: 8/10/2011
  • Posts: 32

Hello,

I have a column in a table that has a large length dimesion. For some reason text is wrapping in this feild when it consists of more than one word even though the feild has plenty of room. Anyone have any thoughts as to how I can stop this from occuring?

Thanks


Posted: 8/16/2011

Starter 727  points  Starter
  • Joined on: 6/6/2011
  • Posts: 74

Hi,

You can achieve this with RowDataBound event, if the length of the string is over some predefined lenght then concatenate the string that is displayed in a row cell, and add tooltip to that cell.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int rowLength = 30;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Text.Lenght > rowLength)
{
e.Row.Cells[4].ToolTip = e.Row.Cells[4].Text;
e.Row.Cells[4].Text = e.Row.Cells[4].Text.Substring(0,rowLength) + "...";
}
}
}

If you need more help, dont hesitate to ask.

Best Regards,

Gjorgji


tags Gridview
Page 1 of 1 (2 items)