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 "fixed" for this to work properly.
gvLinks.Style["TABLE-LAYOUT"] =
"fixed";
Then on each Row_Created event, I can set the other properties:
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.
When using the adapters you have to make these sorts of changes within your style sheets. 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.
toddhd
Contributor
2486 Points
531 Posts
Gridview, the adapters, and overflow options
Sep 19, 2006 01:37 PM|LINK
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 "fixed" for this to work properly.
gvLinks.Style["TABLE-LAYOUT"] = "fixed";
Then on each Row_Created event, I can set the other properties:
e.Row.Cells[1].Wrap = false;
e.Row.Cells[1].Style["overflow"] = "hidden";
e.Row.Cells[1].Style["text-overflow"] = "ellipsis";
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.
http://www.SeaburyDesign.com
Russ Helfand
Contributor
3304 Points
744 Posts
Re: Gridview, the adapters, and overflow options
Sep 19, 2006 03:46 PM|LINK
When using the adapters you have to make these sorts of changes within your style sheets. 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.
In other words, the adapters expect you to have a style sheet like this one, http://www.asp.net/CSSAdapters/srcviewer.aspx?inspect=%2fCSSAdapters%2fApp_Themes%2fBasic%2fGridViewExample.css¬ree=true.
Look at line 42. There's a rule that styles all the cells in the table's body. It looks like it would be the right place to add things like
wrap: false;
overflow: hidden;
text-overflow: ellipsis;
However, I've not actually tried this so I'll be interested to hear if it works for you.
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
table-layout: fixed;
Hope this helps. Let me know if you find that all this is smoke&mirrors in which case I'll try to come up with a different strategy for you. :)
Groovybits.com