|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
wrap text in datagrid celltried 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; } 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 Show quoteHide quote "ireallyneedtoknow2***@yahoo.com" wrote: > 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; > } > > 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
Why Does This Not Work?
Datagrid default date format Reload/refresh data in datagrid Programattically setting gridview to edit mode GridView - Hyperlink wrapping text in datagrid Hiding grid columns based on some value in row DataView Borders Editing/Deleting/Inserting Records using ASPxGridView edit template to edit record with null field |
|||||||||||||||||||||||