Avatar of Prysson
Prysson
 asked on

problem seeting maximum width to gridview coumn

I have a gridview and I want to fix the column size to a certain size regardless of the length of the data in a given cell.
I have tried everythign I can think of from

gvwProjects.Columns[1].ItemStyle.Width

gvwProjects.Columns[1].ItemStyle.Wrap

to setting the length of the lblContol in the template but no matter what I do the column size automatically increases beyond my fixed size to meet the size of the longest cell in the bound datatable.


Anyone have any ideas?
C#.NET Programming

Avatar of undefined
Last Comment
Prysson

8/22/2022 - Mon
Roshan Davis

this liks solved the same problem http://forums.asp.net/t/1213513.aspx

the comment is

You do not need to write any code behind.

GridView will render itself as html element.

So you can write one file named abc.css.

 

table
{
  table-layout:fixed;
}
td
{
  word-wrap:break-word;
}
 

Then all you need to do is to reference it from aspx file using <link href="abc.css" rel="stylesheet" type="text/css" />
Prysson

ASKER
Ive already seen that link and it doesnt make any sense.

Im talking about a gridview how does

<link href="abc.css" rel="stylesheet" type="text/css" />

cause a gridview column to have a fixed column width.

a <link href /> isnt a gridview
Roshan Davis

will this work for you? I mean using a template field
http://msdn.microsoft.com/en-us/library/bb288031.aspx
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Roshan Davis

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Prysson

ASKER
maybe I am missing something here.. I just dont understand how you are getting the gridview to reference the css file to apply the style given the examples above..nowhere do I see any reference to the css file in teh gridview or any of the item templates.

AM I just being blind or obtuse?  
Prysson

ASKER
.