471,338 Members | 1,308 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Re Fixed Columns in DataGrid

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" <mo**@discussions.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
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 #1
0 1309

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by TPSreport | last post: by
1 post views Thread by Lalit Bhatia | last post: by
reply views Thread by Khalid Ashraf | last post: by
reply views Thread by CW | last post: by
2 posts views Thread by CSL | last post: by
10 posts views Thread by Aaron Smith | last post: by
reply views Thread by Lalit Bhatia | last post: by

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.