Posted: 8/13/2011
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
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