Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one

how can i control the width of columns in a Gridview.

Thank you
Posted

Hi,

Grid view design has properties under Edit Columns.

Autosizemode gives various options.

For exact width set autosize to not set and width to the pixels you require.
For columns to fill the whole available space in the table width set autosize to fill.
If you want more than 1 column set to fill then set the fill weight to the percentage space you want that column to fill.
 
Share this answer
 
Comments
Nasser Abu Farah 28-Jan-13 19:38pm    
Thank's a lot
For static columns: Use the HeaderStyle-Width, ItemStyle-Width or FooterStyle-Width properties.
For dynamic columns: Set the above said properties at runtime, like:
C#
GridView1.Columns[i].ItemStyle.Width = colWidth;

Refer:
MSDN: How to: Set GridView Web Server Control Column Width Dynamically[^]
 
Share this answer
 
Comments
deepakaitr12345 22-Jan-13 7:43am    
5+
Nasser Abu Farah 28-Jan-13 19:38pm    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900