Click here to Skip to main content
12,512,130 members (52,432 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Gridview
Hi every one

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

Thank you
Posted 17-Jan-13 6:14am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Nasser Abu Farah 28-Jan-13 19:38pm
   
Thank's a lot
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

For static columns: Use the HeaderStyle-Width, ItemStyle-Width or FooterStyle-Width properties.
For dynamic columns: Set the above said properties at runtime, like:
GridView1.Columns[i].ItemStyle.Width = colWidth;
Refer:
MSDN: How to: Set GridView Web Server Control Column Width Dynamically[^]
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100