0

So I have tried to define the width of the template field in 7 places (ControlStyle-Width, ItemStyle-Width, HeaderStyle-Width, ControlStyle Width, ItemStyle Width, TextBox Width and finally in a css), but it still wraps the content ("1400 kr"). What is the matter here?

 <asp:TemplateField HeaderText="Totalt" ControlStyle-Width="100" ItemStyle-Width="100" ItemStyle-Wrap="True" HeaderStyle-Width="100" ControlStyle-CssClass="wide"> <ItemTemplate> <asp:TextBox ID="tbTotalPrice" runat = server ReadOnly="true" Width="100px"></asp:TextBox> </ItemTemplate> <ControlStyle Width="100px" /> <ItemStyle HorizontalAlign="Right" Width="100px" /> </asp:TemplateField> 

the style sheet:

.wide { width: 120px; column-width: 120px; } 

2 Answers 2

1

Make sure that you didn't give the total width of the Gridview. If you had given total width of the Gridview then remove it.

Also there is no need to give class for Item Template as you had already defined the manual column width.

Sign up to request clarification or add additional context in comments.

3 Comments

the total width of the gridview is not set. I understand that it is overkill to set the width in several places, but I just kept trying new settings as nothing works.
Please remove the width from all the places. Replace your code from <ItemStyle HorizontalAlign="Right" Width="100px" /> to <ItemStyle Width="100px" />. Remove HorizontalAlign="Right" in your item style.
Thanks Azhar. I have made the changes you suggested, but the problem still remained. until I also changed ItemStyle-Wrap="False"
0

use column tags instead of ItemTemplate tags and then set column width. you also 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.

2 Comments

I don't want the text to be wrapped or truncated. I just want the column to be wide enough to dispaly the 5 - 8 characters stored in the field. Are there any column tags that you suggest apart from the ones I have tried?
i think if you set column width like <column style="width:10px"></column> then it should work

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.