jaynilacfar
New Member
Hi, <BR><BR>Hopefully somebody here knows how to constrain the width of a column that a datagrid generates. The problem is that when the datagrid.column is filled with text, rather than go onto seperate lines when the column width is reached it simple extends the datagrids column to accommodate however much text is being passed. I end up with a column about 4 pages wide and have to use a scroll bar. I have tried to use template columns, styles tables u name it. There just doesn't seem to be any way of controlling the column widtgh at runtime.The code im working with right now is shown below. <BR><BR>please help this is driving me mad!!! <BR><BR><asp:datagrid id="DataGrid1" Width="25%" runat="server" AutoGenerateColumns="False"><BR> <HeaderStyle Width="50%" Wrap=False BackColor="DodgerBlue"></HeaderStyle><BR> <Columns><BR> <BR> <asp:BoundColumn HeaderText="MessageTitle" DataField="MessageTitle" ItemStyle-Wrap="False" HeaderStyle-Wrap="False" /><BR> <asp:TemplateColumn ItemStyle-wrap=False ItemStyle-Width="20"><BR> <ItemTemplate ><BR> <div class="ritem"><BR> <BR> <%# DataBinder.Eval(Container.DataItem,"MessageTitle")%><BR> </div> <BR> </ItemTemplate><BR> </asp:TemplateColumn><BR> <BR> </Columns><BR> </asp:datagrid></form><BR>I'm using this bound column format and it seems to work fine. There may be a simpler approach.<BR><BR><ASP:BoundColumn HeaderText = "Date" <BR> DataField = "rDate"<BR> DataFormatString = "{0:d}"<BR> SortExpression = "rDate" ><BR> <ItemStyle Width = "60" /><BR></ASP:BoundColumn>