setting Column width of Template Column in Datagrid..


C

Charleees

Hi all,

I have a DataGrid with Template Columns.....

There are LAbels,Linkbuttons in the Single Row..

I have to set the Constant Column width for those Template Columns in
Grid...

Wat actually happens is... when the Text size is too big... the column
also expands..

But wat actually should happen is ,

The text should wrap within the Column Width,,

I have set the Wrap and Column width Property of The Template Column of
the Grid ...

But it was not working...

The GRid goes as follows..


<asp:datagrid id="DG_Live" runat="server" CssClass="DataGrid"
Width="100%" Height="100%" ItemStyle-BackColor="#EFF7FF"
GridLines="None" AutoGenerateColumns="False" HorizontalAlign="Left"
CellPadding="0" ItemStyle-Height="100" HeaderStyle-Height="100">
<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle"
BackColor="White" > </AlternatingItemStyle>
<ItemStyle Font-Size="11px" Font-Names="Verdana" HorizontalAlign="Left"
Height="30px" VerticalAlign="Middle"
BackColor="#EFF7FF"></ItemStyle>
<HeaderStyle Font-Size="X-Small" Font-Names="Verdana" Font-Bold="True"
HorizontalAlign="Center" Height="40px"
BackColor="White"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<HeaderStyle Width="5%"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr> <td align="left"> <asp:CheckBox ID="check1"
Runat="server"></asp:CheckBox> <asp:Label ID="UniqueId1"
Runat="server" Visible="False" ></asp:Label>
<asp:Label ID="UrlLink1" Runat="server" Visible="False"></asp:Label>
</td> </tr> </table> </ItemTemplate> </asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="5%"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:Label ID="Serial1" Runat="server" Font-Size="11px"
Font-Name="verdana" Font-Bold="False"
Font-Names="verdana"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Pos">
<HeaderStyle Font-Size="11px" Font-Names="verdana" Font-Bold="True"
Width="10%"></HeaderStyle> <ItemStyle Width="10%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:linkbutton ID="Up" Runat="server"
CssClass="LinkButton2" CommandName="Up"></asp:linkbutton>
<asp:linkbutton ID="Down" Runat="server"
CssClass="LinkButton2" CommandName="Down"></asp:linkbutton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Description">
<HeaderStyle Font-Size="11px" Font-Names="verdana"
Font-Bold="True" Width="28%"></HeaderStyle>
<ItemStyle Width="28%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="PADDING-LEFT: 15px" align="left">
<asp:linkbutton ID="Description1" Runat="server"
CssClass="LinkButton3"
CommandName="Description1"></asp:linkbutton></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Image">
<HeaderStyle Font-Size="11px" Font-Names="verdana"
Font-Bold="True" Width="22%"></HeaderStyle>
<ItemStyle Width="22%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:Label ID="Image1" Runat="server"
Font-Size="11px" Font-Name="verdana" Font-Bold="False"
Font-Names="verdana"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Target">
<HeaderStyle Font-Size="11px" Font-Names="verdana"
Font-Bold="True" Width="10%"></HeaderStyle>
<ItemStyle Width="10%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:Label ID="Target1" Runat="server"
Font-Size="11px" Font-Name="verdana" Font-Bold="False"
Font-Names="verdana"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Link">
<HeaderStyle Font-Size="11px" Font-Names="verdana"
Font-Bold="True" Width="15%"></HeaderStyle>
<ItemStyle Width="15%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:Label ID="Link1" Runat="server"
Font-Size="11px" Font-Name="verdana" Font-Bold="False"
Font-Names="verdana"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="TestLink">
<HeaderStyle Font-Size="11px" Font-Names="verdana"
Font-Bold="True" Width="5%"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:linkbutton ID="TestLink1" Runat="server"
CssClass="LinkButton2" CommandName="TestLink1"></asp:linkbutton></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Visible="False"></PagerStyle>
</asp:datagrid>


Please Help .. ITs URgent...

With Regards
Sanju.C
 
Ad

Advertisements

C

Charleees

Thanks Eliyahu ,

I have tried with wat u said.. but could nt..

Is there any other way..
This is a simplw thing but working strange.. I dont know y..

Please Help....

With Regards,
Charles.V
 
Ad

Advertisements

E

Eliyahu Goldin

You can try to make use of css rule table-layout:fixed. Put it in your
DataGrid css class.

Eliyahu
 

Top