467,926 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

setting Column width of Template Column in Datagrid..

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

Jun 20 '06 #1
  • viewed: 10087
Share:
2 Replies
You can try to make use of css rule table-layout:fixed. Put it in your
DataGrid css class.

Eliyahu

"Charleees" <vc********@gmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
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

Jun 20 '06 #2

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

Jun 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by TT (Tom Tempelaere) | last post: by
1 post views Thread by VB Programmer | last post: by
2 posts views Thread by Yama | last post: by
1 post views Thread by Luis Esteban Valencia | last post: by
1 post views Thread by Shapper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.