Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 21st, 2008, 04:53 PM
Friend of Wrox
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default GridView - cell wrapping - need help

I have a GridView where text in cells wrap in the middle if the cell (not utilizing the complete width of the cell). In the properties of the "BoundFields" definition I have set wrap = false. I also tried this:

GridView2.DataSource = Nothing
            GridView2.DataSource = MaterialDetailDataTable
            GridView2.Style.Item("wrap") = False

But it still wraps.

So how do I tell the GridView to use full cell width and not to wrap (in code behind)? Thank you.

<asp:GridView ID="GridView2" runat="server" Style="z-index: 10px; position: relative; top: 43px; border-right: gray thin solid; border-top: gray thin solid; border-left: gray thin solid; border-bottom: gray thin solid; font-size: 12px; left: 10px;" Width="518px" AllowPaging="True" AllowSorting="True" Font-Size="Small" AutoGenerateColumns="False" CellSpacing="2" 
            HorizontalAlign="Left" BorderColor="LightGray" BorderStyle="None" PageSize="14" OnSorting="GridView2_Sorting">
                   <asp:BoundField DataField="job_date" DataFormatString="{0:d}" HeaderText="Date" SortExpression="job_date" HtmlEncode="False">
                       <ItemStyle HorizontalAlign="Center" Width="20px" />
                   <asp:BoundField DataField="item_number" HeaderText="Cost Code" HtmlEncode="False">
                       <ItemStyle HorizontalAlign="Left" Width="30px" />
                   <asp:BoundField DataField="source_name" HeaderText="Source Name">
                       <ItemStyle HorizontalAlign="Left" Width="90px" Wrap="False" />
                   <asp:BoundField DataField="product_name" HeaderText="Product Name">
                       <ItemStyle HorizontalAlign="Left" Width="90px" Wrap="False" />
                   <asp:BoundField DataField="item_qty" HeaderText="Quantity">
                       <ItemStyle HorizontalAlign="Right" Width="30px" Wrap="False" />
                   <asp:ButtonField CommandName="notes" DataTextField="item_notes" HeaderText="Notes"
                       Text="notes" >
                       <ItemStyle Width="80px" Wrap="False" />
                <HeaderStyle BackColor="#FFC080" Height="35px" />
                <AlternatingRowStyle BackColor="#FFFFC0" /> 
                <RowStyle Height="20px" Wrap="False" />
                <SelectedRowStyle BackColor="#FF8080" Wrap="False" />

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
Change value in GridView Cell Sheraz Khan ASP.NET 2.0 Professional 2 August 30th, 2007 11:12 AM
Problem in Gridview Cell Lalit Pradhan ASP.NET 2.0 Professional 2 August 1st, 2007 04:08 AM
How to change the value of one cell in a GridView? jameslin288@yahoo.com ASP.NET 2.0 Basics 8 November 19th, 2006 01:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.