473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 2689
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
2
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.