views:

44

answers:

2

My DataGrid contain totally 32 columns.I need to display my first 4 column as default column. For the remaining Column i need to view using scroll bar.(not Page scroll need scroll bar inside my grid view)

A: 

Try this

<asp:GridView ID="GridView1" runat="server">
<Columns>
  <asp:BoundField HeaderText="Column 1" />
  <asp:BoundField HeaderText="Column 2" />
  <asp:BoundField HeaderText="Column 3" />
  <asp:BoundField HeaderText="Column 4" />
  <asp:TemplateField>
    <ItemTemplate>
      <div style="overflow: scroll; width: 400px;">
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Column 5") %>'></asp:Label>
        <asp:Label ID="Label3" runat="server" Text='<%# Eval("Column 6") %>'></asp:Label>
        <asp:Label ID="Label4" runat="server" Text='<%# Eval("Column 7") %>'></asp:Label>
        <asp:Label ID="Label5" runat="server" Text='<%# Eval("Column 8") %>'></asp:Label>
        <asp:Label ID="Label6" runat="server" Text='<%# Eval("Column 9") %>'></asp:Label>
        ....
        <asp:Label ID="Label7" runat="server" Text='<%# Eval("Column 32") %>'></asp:Label>
      </div>
    </ItemTemplate>
  </asp:TemplateField>
</Columns>

alejandrobog
thank u.........
Ayyappan.Anbalagan
A: 

When I've had to do this, what I did was create 2 Gridviews next to each other The first Gridview should have only the freezable columns. The second will have the rest, and will be in a scrollable div tag.

I had defined amount of of rows, so it wasn't a problem for me, but if you scroll down on one grid, the rows won't match the second grid.

Here's another solution using CSS..but I haven't tried it: http://www.codeproject.com/KB/webforms/FreezePaneDatagrid.aspx

If you use third party controls like the Telerik RadGrid, they usually have built in properties to control Freezing Columns.

Ed B