how get a fixed colum size in datagrid

wbb

Newcomer
Joined
Jan 19, 2004
Messages
21
i having datagrid column size's problem ...if the grid does not have enough item number i set in page size...the grid's column will become BIG and UglY...anyone here know hw to set it a standard fixed size ....
 
If you don't allow wrap the column will get very wide, if you do allow wrap it will get very tall. I prefer to limit the amount shown in that column/cell to a pre-determined length....You can place a button or something to allow the user to select then view the entire content in a textArea.

Code:
[size=2][color=#0000ff]Public[/color][/size][size=2][color=#0000ff]Function[/color][/size][size=2] LimitChars([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] s [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Object[/color][/size][size=2]) [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String[/color][/size]
[color=#0000ff]	[size=2]If[/size][/color][size=2] IsDBNull(s) [/size][size=2][color=#0000ff]Then[/color][/size]
[color=#0000ff]		 [size=2]Return[/size][/color][size=2] ""[/size]
	[size=2][color=#0000ff]Else[/color][/size]
[color=#0000ff]		 [size=2]Dim[/size][/color][size=2] ss [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String[/color][/size][size=2] = Convert.ToString(s)[/size]
		 [size=2][color=#0000ff]Dim[/color][/size][size=2] len [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer[/color][/size][size=2] = ss.Length[/size]
		 [size=2][color=#0000ff]If[/color][/size][size=2] len > 30 [/size][size=2][color=#0000ff]Then[/color][/size]
[size=2]len = 30[/size]
		 [size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If[/color][/size]
[color=#0000ff]		 [size=2]Return[/size][/color][size=2] ss.Substring(0, len)[/size]
	[size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If[/color][/size]
[size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Function
[/color][/size]
In your aspx page, Label or Literal text...
Code:
text='<%# LimitChars(DataBinder.Eval(Container, "DataItem.myColumn")) %>'
 
Back
Top