Gridview, the adapters, and overflow optionshttp://forums.asp.net/t/1027656.aspx/1?Gridview+the+adapters+and+overflow+optionsTue, 19 Sep 2006 15:46:45 -040010276561403681http://forums.asp.net/p/1027656/1403681.aspx/1?Gridview+the+adapters+and+overflow+optionsGridview, the adapters, and overflow options <p>We have several web parts that use gridview controls. Because the web parts can and do resize frequently, we often need to account for text that is longer than the grid column. We do this by setting the overflow properties to that the text is truncated and ellipsis(...) are shown instead. I've found through trial and error that that Table-Layout style property of the table needs to be set to &quot;fixed&quot; for this to work properly. </p> <font size="2"> <p>gvLinks.Style[<font color="#800000" size="2">&quot;TABLE-LAYOUT&quot;</font><font size="2">] = </font><font color="#800000" size="2">&quot;fixed&quot;</font><font size="2">;</font></p> </font> <p><font size="2">Then on each Row_Created event, I can set the other properties:</font></p> <font size="2"><font size="2"> <p>e.Row.Cells[1].Wrap = <font color="#0000ff" size="2">false</font><font size="2">;<br> e.Row.Cells[1].Style[</font><font color="#800000" size="2">&quot;overflow&quot;</font><font size="2">] = </font><font color="#800000" size="2">&quot;hidden&quot;</font><font size="2">;<br> e.Row.Cells[1].Style[</font><font color="#800000" size="2">&quot;text-overflow&quot;</font><font size="2">] = </font><font color="#800000" size="2">&quot;ellipsis&quot;</font><font size="2">;</font></p> </font> <p><font size="2">When I load the CSS adapters, even before I load any theme files, this stops working. I assume some sort of rerendering is going on. How can I fix this? Note that all of our controls are dynamically generated, as we are building server controls.</font></p> </font> 2006-09-19T13:37:06-04:001403888http://forums.asp.net/p/1027656/1403888.aspx/1?Re+Gridview+the+adapters+and+overflow+optionsRe: Gridview, the adapters, and overflow options <p>When using the adapters you have to make these sorts of changes within your style sheets.&nbsp; The adapters assume that you'll have linked (either directly or automatically by using a theme) to a style sheet that sets up CSS rules for the HTML that the adapter is know to spit out.</p> <p>In other words, the adapters expect you to have a style sheet like this one, <a href="http://www.asp.net/CSSAdapters/srcviewer.aspx?inspect=%2fCSSAdapters%2fApp_Themes%2fBasic%2fGridViewExample.css&amp;notree=true"> http://www.asp.net/CSSAdapters/srcviewer.aspx?inspect=%2fCSSAdapters%2fApp_Themes%2fBasic%2fGridViewExample.css&amp;notree=true</a>.</p> <p>Look at line 42.&nbsp; There's a rule that styles all the cells in the table's body.&nbsp; It looks like it would be the right place to add things like</p> <p>wrap: false;<br> overflow: hidden;<br> text-overflow: ellipsis;</p> <p>However, I've not actually tried this so I'll be interested to hear if it works for you.</p> <p>It also looks like you'll want to modify a rule for the whole table, like the rule on line 21. To it you might add</p> <p>table-layout: fixed;</p> <p>Hope this helps.&nbsp; Let me know if you find that all this is smoke&amp;mirrors in which case I'll try to come up with a different strategy for you. :)</p> 2006-09-19T15:46:45-04:00