I use a gridview control to display the data from database. However, there are some columns have large text, these text automatically turns to a new line which is not good. How can I adjust the column width based on its content?
Click the smart tag on the upper right corner of your GridView control and select Edit Columns. Go to each of your columns and under Styles -> ItemStyle set the Wrap property to False.
My Blog
http://Lspence.blogspot.com
(Please MARK this post as ANSWERED, if you find it helpful)
Thank you lspence, i set autogeneratecolumns property to true.. so, i cannot set the ItemStyle via edit columns. But i think it will help next time if i use manaully bind gridview columns.
Yoona
None
0 Points
8 Posts
Gridview size column width based on the cell content
Jan 16, 2013 04:05 PM|LINK
I use a gridview control to display the data from database. However, there are some columns have large text, these text automatically turns to a new line which is not good. How can I adjust the column width based on its content?
lspence
Star
11493 Points
1707 Posts
Re: Gridview size column width based on the cell content
Jan 16, 2013 05:11 PM|LINK
Click the smart tag on the upper right corner of your GridView control and select Edit Columns. Go to each of your columns and under Styles -> ItemStyle set the Wrap property to False.
http://Lspence.blogspot.com
(Please MARK this post as ANSWERED, if you find it helpful)
velambath
Member
396 Points
111 Posts
Re: Gridview size column width based on the cell content
Jan 16, 2013 06:20 PM|LINK
Hi,
for the column(s) you are having this lengthly text apply a css property : white-space:nowrap;
Hop ths will solve your issue :)
- Rigin
Yoona
None
0 Points
8 Posts
Re: Gridview size column width based on the cell content
Jan 17, 2013 01:46 AM|LINK
@ lspence,
Thank you lspence, i set autogeneratecolumns property to true.. so, i cannot set the ItemStyle via edit columns. But i think it will help next time if i use manaully bind gridview columns.
Yoona
None
0 Points
8 Posts
Re: Gridview size column width based on the cell content
Jan 17, 2013 01:47 AM|LINK
@velambath,
Your answer does solve my issue. Thanks you.
velambath
Member
396 Points
111 Posts
Re: Gridview size column width based on the cell content
Jan 20, 2013 05:29 AM|LINK
Very happy to hear that . . . : )
enjoy . . have a nice day
- Rigin