GridView Column Width

we have a gridview that we are manually setting up the columns in.

the column widths are defined by the user, but occasionly they specify a width that is smaller than required for the heading text.

the gridview automatically resizes the column and makes the other columns slightly smaller to fix this up.

the problem is that we dynamically add controls above and below the gridview to filtering and totalling so when the gridview is automatically resized the controls dont match up.

when we ask the column width, even after calling the databind method, it returns the width we set it as, not what it has been resized too.

how do i get the real column width.

note: when i talk about columns, i'm referrring to DataControlField's which are what dataview's call columns.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How is width set? By %? What are default settings for all columns (% or px)?
mpdaltonAuthor Commented:
they are in px

Dim dgc As DataGridColumnStyle
   dgc = DataGrid1.TableStyles(0).GridColumnStyles("id")
   dgc.Width = 500
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

i suspect that what is happening is the browser is doing the 'resizing' to fit its contents. The code that your aspx page produces will have the correct column width for each column - but the browser needs to enlarge the column to fit it all in.

look at the page source of a page with problems and see what the column width is. this will tell you if its the aspx or the browser doing the resizing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mpdaltonAuthor Commented:
hi solar_flare, you are right, the html is correct when i view the source, so it's the brower that is causing the problem.

any ideas how to override this behaviour so it maybe auto truncates the field or wraps it ? the column heading is already set to wrap but this only works when there are multiple words to a heading not one long word.
browsers would not be capable of truncating or wahtever, you would have to rename the columns so they are short enought to fit or change the font size

for each c as datacolumn in yourDatatable.Columns
    if c.ColumnName.Length > 10 then c.columnName = c.ColumnName.Substring(0, 10)


something like that in your codebehind would stop the headings being too long, butmight make it look ugly?

maybe resize the font of the header based on the length of the longest word so it wraps correctly? this would be more coding but might look better.
mpdaltonAuthor Commented:
thanks for your help solar_flare. now that i know the limitiations of the browser i can let the project sponsor know that users will just have to check during table setup that the field width is wide enough.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.