Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

wrap text in datagrid cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ireallyneedtoknow2007@yahoo.com - 12 Nov 2007 13:17 GMT
here is a cleaner version of a question I posted yesterday.  I have
tried many versions of the code below but cannot get the column to
wrap.  I am using asp.net 2.0 visual studio 2005.  ultimately I will
be adding template columns as well, but really need this column to
wrap.  thanks for your help

<asp:datagrid id="myDataGrid" style="Z-INDEX: 100; LEFT: 20px;
POSITION: absolute; TOP: 260px" runat=server
    AllowSorting="True"  Font-Size="X-Small" Font-Names="Verdana"
ForeColor="Black"
    GridLines="None" CellPadding="2" BackColor="LightGoldenrodYellow"
BorderWidth="1px"
    BorderColor="Tan" Width="100px" Height="304px"
OnPreRender="myDataGrid_PreRender" AutoGenerateColumns="False"
    BorderStyle="Solid" CellSpacing="2">

    <Columns>
        <asp:BoundColumn DataField="contact_email" ReadOnly="True"
HeaderText="Emailx">
            <ItemStyle Wrap="True" ></ItemStyle>
            <HeaderStyle Width="5px"  Wrap=true/>
        </asp:BoundColumn>
    </Columns>

</asp:datagrid>

public void myDataGrid_PreRender(object sender, System.EventArgs e)
{
    myDataGrid.Columns[0].ItemStyle.Width = 30;
    myDataGrid.Columns[0].ItemStyle.Wrap = true;
}
Peter Bromberg [C# MVP] - 12 Nov 2007 15:48 GMT
Take a look at "word-break:break-word" and similar CSS style behaviors.
-- Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com

> here is a cleaner version of a question I posted yesterday.  I have
> tried many versions of the code below but cannot get the column to
[quoted text clipped - 27 lines]
>     myDataGrid.Columns[0].ItemStyle.Wrap = true;
> }
ireallyneedtoknow2007@yahoo.com - 12 Nov 2007 23:00 GMT
thanks, no doubt I did something wrong but I could not get <style> to
work.  however replacing a comma with a comma<br> in my sql did give
me what I needed.

<style>
 .fixed_cell
 {
    word-wrap:break-word;
    width:25px;
 }
</style>

<asp:BoundColumn DataField="contact_email" ReadOnly="True"
HeaderText="Email" ItemStyle-CssClass="fixed_cell" >

select replace(contact_email,',',',<br>') as contact_email from mytable

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.