Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview Column widths

Status
Not open for further replies.

stephenk1973

Technical User
Jun 11, 2003
246
GB
I have a gridview for which i cannot nail down the column widths, it always seems to be dependent on the data returned. Usually its variable length text field which throw the spanner.

How can I nail these values down.

Alternatively I have seen a property you can set in the css table format- table-layout: fixed, how can set this against this gridview only.

Thanks

Stephen
 
I'm not sure how you are currently specifying the widths...can you provide an example of what you are trying and are sayind doesn't work?
Alternatively I have seen a property you can set in the css table format- table-layout: fixed, how can set this against this gridview only.
As with any control, you can either set the style of the control to include the relevant CSS (e.g style="table-layout: fixed;"), or you could give it a CssClass and use the CSS file to specify the format, or you could even do it in the CSS file based on the ID of the GridView.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 

Numerous rows but all of either template or bound ( example cut of code below), the item style width is defined for all fields.

The fields 'text' value is occsionally longer than the field, this automatically increaces the row height as it wraps to a second line within the field. If i could stop this i think i would be okay. I have tried settign wrap to false but no difference.

There is also an event which fires on the mouseover-row which renames the label in the header to an appropriate value for that row.

The gird always seems to fit to the screen, i think this is occuring and adjusting the columns widths?

Help appreciated.

Thanks

Stephen

<asp:BoundField DataField="TOTAL"
HeaderText="TOTAL"
SortExpression="TOTAL" >
<ItemStyle Wrap="True" Width="50px" HorizontalAlign="Right"/>
<HeaderStyle Wrap="True" />
</asp:BoundField>

<asp:TemplateField HeaderText="S1">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("S1") %>'></asp:TextBox>
</EditItemTemplate>
<HeaderTemplate><label for="S1" id="label5">SIZE 1</label></HeaderTemplate>
<ItemStyle HorizontalAlign="Right" Width="50px" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("S1") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Wrap="True" />
</asp:TemplateField>
 
I have it sorted now. I had been defining the gridview width, the column item width definitions had crept above the overall gridview width and this was giving the grid a slightly unpredictable approach to column sizing especially when the mouse over event fired a renaming script for some header labels.

Thanks

Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top