Set length of perticuler column in gridview - C#.Net

Posted by Ganesh under C# on 12/3/2008 | Views : 4917 | Status : [Member] | Replies : 1
I have 5 columns in gridview. In 5th column, data has avg of 200 bytes. So the entire row is resized according with the total number of text.

My requirement is fix the 5th column size should be 10 followed by "...". When I move to mouse over this 5th column, the remaining data should be show tooltip.


Posted by: Poster on: 12/6/2008 [Member] Starter

You can use this function to limit the length of the text,

public static string WriteStringForSpecificLength(string str, int length)

int len = str.Length;
if (len > length)
len = length;
return str.Substring(0, len) + " ...";


This will return the string passed into this function but with limited characters (passed as 2nd parameter).

Further again call the same string and use some javascript function on mouseover to show the entire text.

Hope this will give some hint.

Ganesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response