setting Column width of Template Column in Datagrid..

Discussion in 'ASP .Net' started by Charleees, Jun 20, 2006.

  1. Charleees

    Charleees Guest

    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
     
    Charleees, Jun 20, 2006
    #1
    1. Advertising

  2. Charleees

    Charleees Guest

    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
     
    Charleees, Jun 20, 2006
    #2
    1. Advertising

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

    Eliyahu

    "Charleees" <> wrote in message
    news:...
    > 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
    >
     
    Eliyahu Goldin, Jun 20, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    1
    Views:
    5,038
    VB Programmer
    Aug 4, 2004
  2. AndrewF
    Replies:
    1
    Views:
    808
    Bruce Barker
    Oct 10, 2005
  3. ppcguy
    Replies:
    3
    Views:
    1,287
    Toby Inkster
    Aug 26, 2005
  4. Replies:
    0
    Views:
    500
  5. Carl Howarth

    DG Column Width vs Table Column Width

    Carl Howarth, Oct 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    276
    Eliyahu Goldin
    Oct 24, 2004
Loading...

Share This Page