471,066 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

web datagrid column width

nj
I am trying to set the width of a single column in the datagrid. What is happening is the column seems to stretch to try to accomodate the length of the data contained in it. I want to have it only x number of pixels wide and the data to wrap if necessary. I have tried several things to set the column width but it seems to ignore everything I try.

I have tried:
1. Setting the width of the grid to be 50% - still stretches across entire screen.
2. Executing e.Item.Cells(0).Width = New Unit(100) in the itemdatabound event- doesn't do anything
3. Executing e.Item.Cells(0).Width = New Unit(100) in the itemcreated event- doesn't do anything

The grid itself is contained in an html table because there are several other grids on the screen and I want to make sure they don't overlap each other.

Any ideas of what I may be doing wrong or how to make it work... If it will

Thanks
Nov 18 '05 #1
2 2576
You don't have full control over column width. The browser considers your
instructions as recommendations. You can trick it a bit though. If I want a
column to be as narrow as possible, I set its width to 1px. Then it will get
the width of the longest first word in the column and the next words will be
wrapped.

Eliyahu

"nj" <nj@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
I am trying to set the width of a single column in the datagrid. What is happening is the column seems to stretch to try to accomodate the length of
the data contained in it. I want to have it only x number of pixels wide and
the data to wrap if necessary. I have tried several things to set the column
width but it seems to ignore everything I try.
I have tried:
1. Setting the width of the grid to be 50% - still stretches across entire screen. 2. Executing e.Item.Cells(0).Width = New Unit(100) in the itemdatabound event- doesn't do anything 3. Executing e.Item.Cells(0).Width = New Unit(100) in the itemcreated event- doesn't do anything
The grid itself is contained in an html table because there are several other grids on the screen and I want to make sure they don't overlap each
other.
Any ideas of what I may be doing wrong or how to make it work... If it will
Thanks

Nov 18 '05 #2
nj,

It may depend on the content in the cell. If that content has no break
points (a space, hyphen, etc.) that the browser will automatically wrap on
then that may be the cause. Each browser treats this situation differently.
The safe thing to do, if it is that the content has no break points, is to
insert some character that the grid will wrap with.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"nj" <nj@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
I am trying to set the width of a single column in the datagrid. What is happening is the column seems to stretch to try to accomodate the length of
the data contained in it. I want to have it only x number of pixels wide and
the data to wrap if necessary. I have tried several things to set the column
width but it seems to ignore everything I try.
I have tried:
1. Setting the width of the grid to be 50% - still stretches across entire screen. 2. Executing e.Item.Cells(0).Width = New Unit(100) in the itemdatabound event- doesn't do anything 3. Executing e.Item.Cells(0).Width = New Unit(100) in the itemcreated event- doesn't do anything
The grid itself is contained in an html table because there are several other grids on the screen and I want to make sure they don't overlap each
other.
Any ideas of what I may be doing wrong or how to make it work... If it will
Thanks

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by web1110 | last post: by
2 posts views Thread by CSL | last post: by
6 posts views Thread by Agnes | last post: by
2 posts views Thread by cj | last post: by
2 posts views Thread by =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.