Link to home
Start Free TrialLog in
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?
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

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" />
Avatar of Prysson
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
will this work for you? I mean using a template field
http://msdn.microsoft.com/en-us/library/bb288031.aspx
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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?  
Avatar of Prysson

ASKER

.