473,386 Members | 1,790 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,386 software developers and data experts.

Fixed columns in DataGrid

how can we fix first column in DataGrid?
Regards,
Lalit Bhatia
Jul 21 '05 #1
1 2415
Hi Lalit,

To make a a column fixed or frozen in a datagrid, you would first need to
have
two tables inside a table. One table would contain the fixed column and the
other
table would contain the rest of the columns.Also, since the first column in
the second
table does not need to show up, you would need to set it's visibility to
False as follows:

<asp:datagrid id="DataGrid1" runat="server" Height="368px" Width="1000px"
ShowHeader="True"
AutoGenerateColumns="False" CellPadding="0" CellSpacing="0" BorderWidth="1">
<Columns>
<asp:BoundColumn DataField="EmployeeName" Visible="False"
HeaderText="EmpName">
<HeaderStyle Width="200px" Height="10px"></HeaderStyle>

You can use a Repeater Control with Header Template and Item template to
pouplate
the fixed column.

Following is the code for the same:

<table width="50px" border="1" cellpadding="0" cellspacing="0">
<asp:Repeater ID="rpt1" Runat="server">
<HeaderTemplate>
<tr>
<td style="height: 1px; padding-left: 5px padding-right: 5px;
padding-top: 6px; padding-bottom: 12px;
border-width: 1px; font-size: 14px;">Employee Name</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="50px" style="height: 1px; padding-left: 5px
padding-right: 5px; padding-top: 6px; padding-bottom: 6px;
border-width: 1px; font-size: 14px;">
<%# DataBinder.Eval(Container.DataItem, "EmployeeName") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td height="1px">&nbsp;</td>
</tr>
</table>

HTH

Mona[Grapecity]

You can set the datasource of the Repeater control and then bind it.
"Lalit Bhatia" <xy*@abc.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
how can we fix first column in DataGrid?
Regards,
Lalit Bhatia

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TPSreport | last post by:
ASP.NET 2003. Two DataGrids, six columns each, one grid atop the other. I need to have the columns line up, i.e., DataGrid1 Col(1) lined up w/ DataGrid2 Col(1) - each the same width on the...
0
by: Lalit Bhatia | last post by:
thanks for the answer but I need it for windows forms. I have a desktop application where I need to implement this. -- Regards, Lalit Bhatia "Mona" <mona@discussions.microsoft.com> wrote in...
1
by: Napo | last post by:
Hi i have about twenty columns displayed in a datagrid,and the first column is "EmployeeID" column.Now,i want to display the "EmployeeID" column awalys when i drag the datagrid's scrollbar.What can...
0
by: Khalid Ashraf | last post by:
Hi, Can somebody point to a code example that shows how to create fixed columns (instead of the 1st left most column) in DataGrid. Thanks in advance.
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
0
by: CW | last post by:
I didn't have If !Page.IsPostBack //bind data source in the code "CW" <a> wrote in message news:um9MTUzFEHA.2560@TK2MSFTNGP12.phx.gbl... > I am taking the Commerce Starter Kit sample from...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
10
by: Aaron Smith | last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the grid will show the 4 rows. However, there is blank space below that until it reaches the bottom of the grid. Is there a way...
1
by: Lalit Bhatia | last post by:
how can we fix first column in DataGrid? Regards, Lalit Bhatia
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.