Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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 ....
  • Moderators
Posted

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.

 

[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...

text='<%# LimitChars(DataBinder.Eval(Container, "DataItem.myColumn")) %>'

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...