HighTechTalks DotNet Forums  

wrap text in datagrid cell

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss wrap text in datagrid cell in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
ireallyneedtoknow2007@yahoo.com
 
Posts: n/a

Default wrap text in datagrid cell - 11-12-2007 , 08:17 AM






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;
}


Reply With Quote
  #2  
Old   
Peter Bromberg [C# MVP]
 
Posts: n/a

Default RE: wrap text in datagrid cell - 11-12-2007 , 10:48 AM






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



"ireallyneedtoknow2007 (AT) yahoo (DOT) com" wrote:

Quote:
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;
}



Reply With Quote
  #3  
Old   
ireallyneedtoknow2007@yahoo.com
 
Posts: n/a

Default Re: wrap text in datagrid cell - 11-12-2007 , 06:00 PM



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


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.