web datagrid column width

G

Guest

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
 
S

S. Justin Gengo

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 said:
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.
 
E

Eliyahu Goldin

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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top