473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
2 10362
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TT (Tom Tempelaere) | last post by:
Hi l&g It's weird but I can't find an easy way to set the width of a column in a DataGrid. It must be hidden somewhere. I searched google but it's all vb-ish and not to the point. Can someone...
1
by: VB Programmer | last post by:
I have a datagrid which is bound to a datatable that I create on the fly. How do I set the width of each column via code? Ex: Column 1 is always 100, Column 2 is always 250, etc... Thanks!
2
by: Yama | last post by:
Hi, How can I make it resizable? For example: <pre> <!-- datagrid Header --> <table class="TableHeader" id="tblHeader" border="1" runat="server">
1
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much...
1
by: headbig003 | last post by:
Hello I put template column in datagrid. Below is the html code I used. <asp:datagrid id="dgAnswer" runat="server" Width="360px" AutoGenerateColumns="False" DataKeyField="ansID"> <Columns>...
0
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater)....
1
by: Shapper | last post by:
Hello, I have a datagrid with one template column and 2 bound columns. I need to set the width of each column. How to do it? I was able to set the width of the entire datagrid but not of...
6
by: cr113 | last post by:
I'm trying to set the column widths for a datagrid. You'd think it would be easy. I looked it up in google and the first thing I found looked promising: datagrid1.columns(0).width = 2000...
4
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.