Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi, i am generating td in codebehide using string str ="";
and then concentrating it.

C#
string str="";

string msg="ffffffffffffffffffffffffff ffffffffffffffff hhhhhhhhhhhhhhhhh gggggggggg ggggggggggggggg gggggggggggggggggg gggggggggggg jjjjjjjjjjjjjjj hello ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffff ffffffffff";


+msg+


I am generating td in codebehind
if i reduced the length of string msg then height of td reduces and if i increase the string length of string msg then height of that td increase. Actually I want whenever the td has two line of text ,I want a scroll bar sbould be appear to my uppermost div.The data in the td is coming from database ,it can be of any size.also there can be n number of td (its dynamic).I want srollbar in uppermost div .
For this i had done some RND as
first i have find how much lengh the first line can take let say 200
then i have check if(len>400)
{
divid.Attributes.Add("style", "height:50px;overflow:auto;");
}
Its giving me what i want but in some cases it fails ,this is not 100% solution .I Want a 100% solution.I want to determine number of line td will increase .Please Help
Posted
Updated 14-Jul-12 12:34pm
v4
Comments
Sergey Alexandrovich Kryukov 13-Jul-12 20:18pm    
Why? This way, you would risk that some content elements would not fit. At the same time, the table by default adjusts itself to fit everything in all rows and columns. I see no reason to require what you do.
--SA
software_Engi08 14-Jul-12 4:41am    
but I have a requirement like this,if td text value increses by 2 line then i should get some message, that why
Sandeep Mewara 14-Jul-12 4:53am    
We cannot work out what and why you are trying to do. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
software_Engi08 15-Jul-12 14:11pm    
Actually I want whenever the td has two line of text ,I want a scroll bar sbould be appear to my uppermost div.The data in the td is coming from database ,it can be of any size.also there can be n number of td (its dynamic).I want srollbar in uppermost div .
For this i had done some RND as
first i have find how much lengh the first line can take let say 200
then i have check if(len>400)
{
divid.Attributes.Add("style", "height:50px;overflow:auto;");
}
Its giving me what i want but in some cases it fails ,this is not 100% solution .I Want a 100% solution.I want to determine number of line td will increase .Please Help

1 solution

Set your td height to auto in css it is easier.if not try this http://stackoverflow.com/questions/4802288/create-html-table-from-a-list-in-c-sharp[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900