473,654 Members | 3,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fixed columns in DataGrid

how can we fix first column in DataGrid?
Regards,
Lalit Bhatia
Jul 21 '05 #1
1 2437
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="Tru e"
AutoGenerateCol umns="False" CellPadding="0" CellSpacing="0" BorderWidth="1" >
<Columns>
<asp:BoundColum n DataField="Empl oyeeName" Visible="False"
HeaderText="Emp Name">
<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.Data Item, "EmployeeNa me") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td height="1px">&n bsp;</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%******** ********@TK2MSF TNGP10.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
5233
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 screen. All columns have the same width assigned via Property Builder, and both DataGrids themselves have the same fixed width. Wrap is OFF for each column item because I can only afford the real estate for a single line; the users should have to...
0
1449
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 message news:OQ0wkCeZFHA.3220@TK2MSFTNGP14.phx.gbl... > Hi Lalit,
1
3769
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 i do Thanks
0
267
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
840
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 controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
0
904
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 asp.net and trying to add a > page that allows user to edit product categories.
2
6397
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
8117
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 to have a fixed number of rows regardless of what data is in the bound table? Thanks, Aaron -- --- Aaron Smith
1
541
by: Lalit Bhatia | last post by:
how can we fix first column in DataGrid? Regards, Lalit Bhatia
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.