Click here to Skip to main content
15,868,070 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,


I have a gridview having 5 databound column.

I want to set all the column's width to 100px.

I did it via column Item-Style properties, but after binding data to gridview its
enlarging according to the cell text.



How can i fix it?



Can you please help me?
Posted

You can use style="white-space: nowrap;overflow: hidden;" which will truncate the text if it is larger than column width. You can use style="overflow: hidden;" if you want your text to be wrapped.
 
Share this answer
 
v3
Comments
kishore Rajendran 20-Jan-12 1:55am    
Thanks for your reply, But its seems in effective for my gridview.
Prerak Patel 20-Jan-12 3:09am    
Saying ineffective is not effective either. Describe what problem you got, or share some relevant code so that we can help better.
It is Easy and ok solution

<asp:boundfield datafield="BranchName" headertext="Branch Name" xmlns:asp="#unknown">
<HeaderStyle Width="300px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>
<itemstyle width="300" horizontalalign="Left" wrap="False">
 
Share this answer
 
Comments
[no name] 5-Mar-13 8:22am    
You just broke up a one year old topic ! ffs
Member 12133159 15-Feb-16 1:42am    
Thanks for the Solution... Worked perfectly
XML
It will add a tag on every column as

<HeaderStyle Width="100px" />
 
Share this answer
 

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