Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2004, 06:04 AM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid fix Header row

Hi,
I want to display more than 500 rows at a time and I am not intrested in paging. when user will scroll the page / datagrid to view records he can view the header always.
so plz. help me.

 
Old December 31st, 2004, 02:01 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

1. This can be done by having DataGrid within Div tag and the set the overflow attribute as auto or scroll.

2. To freeze the headers hide the DataGrid’s headers -- by setting “ShowHeader” property of DataGrid to false.

For example check out the below code snippet,

<div>
    <table border="1" cellspacing="0" style="WIDTH:800px;BORDER-COLLAPSE:collapse">
        <tr class="tableHeader" bgcolor="#aaaadd" BorderColor="black">
            <td style="WIDTH:200px">
                Row Number
            </td>
            <td style="WIDTH: 200px">
                Company Name
            </td>
            <td style="WIDTH:200px">
                Contact Name
            </td>
            <td style="WIDTH:200px">
                Address
            </td>
        </tr>
    </table>
</div>

<div style=" OVERFLOW: auto; WIDTH: 813px; HEIGHT: 152px">
    <asp:DataGrid id="DataGrid1" runat="server" SelectedItemStyle-BackColor="#99ccff" PagerStyle-
        Visible="False" PageSize="10" ItemStyle-CssClass="tableItem" HeaderStyle-
        CssClass="tableHeader" HeaderStyle-BackColor="#aaaadd" BorderColor="black"
        AutoGenerateColumns="False" DataKeyField="CustomerID" ShowHeader="False">

        <Columns>

            <asp:templatecolumn ItemStyle-Width="200px">
                <itemtemplate>
                    <%# Container.ItemIndex+1 %>
                </itemtemplate>
            </asp:templatecolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" taField="CompName">
            </asp:boundcolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" DataField="ContName" >
            </asp:boundcolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" DataField="Address" >
            </asp:boundcolumn>

        </Columns>
    </asp:DataGrid>
</div>

You can extend it by setting the headers width dynamically by finding out the max data size in each column.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old October 26th, 2007, 12:17 AM
Registered User
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to chandanakiran
Default

i have to generate the column names dynamically and fix the header.
i have to display 180 columns and 500 rows with header fixed

Help me

i can't use the below code,b'coz i will get the columns names at runtime.

Quote:
quote:Originally posted by Vadivel
 1. This can be done by having DataGrid within Div tag and the set the overflow attribute as auto or scroll.

2. To freeze the headers hide the DataGrid’s headers -- by setting “ShowHeader” property of DataGrid to false.

For example check out the below code snippet,

<div>
    <table border="1" cellspacing="0" style="WIDTH:800px;BORDER-COLLAPSE:collapse">
        <tr class="tableHeader" bgcolor="#aaaadd" BorderColor="black">
            <td style="WIDTH:200px">
                Row Number
            </td>
            <td style="WIDTH: 200px">
                Company Name
            </td>
            <td style="WIDTH:200px">
                Contact Name
            </td>
            <td style="WIDTH:200px">
                Address
            </td>
        </tr>
    </table>
</div>

<div style=" OVERFLOW: auto; WIDTH: 813px; HEIGHT: 152px">
    <asp:DataGrid id="DataGrid1" runat="server" SelectedItemStyle-BackColor="#99ccff" PagerStyle-
        Visible="False" PageSize="10" ItemStyle-CssClass="tableItem" HeaderStyle-
        CssClass="tableHeader" HeaderStyle-BackColor="#aaaadd" BorderColor="black"
        AutoGenerateColumns="False" DataKeyField="CustomerID" ShowHeader="False">

        <Columns>

            <asp:templatecolumn ItemStyle-Width="200px">
                <itemtemplate>
                    <%# Container.ItemIndex+1 %>
                </itemtemplate>
            </asp:templatecolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" taField="CompName">
            </asp:boundcolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" DataField="ContName" >
            </asp:boundcolumn>
            <asp:boundcolumn ItemStyle-Width="200px" runat="server" DataField="Address" >
            </asp:boundcolumn>

        </Columns>
    </asp:DataGrid>
</div>

You can extend it by setting the headers width dynamically by finding out the max data size in each column.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
cheers,
chandana.
 
Old October 27th, 2007, 12:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Hi:
[u]IN client side (in DataSet)</u>
u may have a fast loop on it to get d Max length of each columns & ...
or[u]Server Side</u>
u can first get ur Max length of columns & ...

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to freeze(fix) datagrid header rsanuj ASP.NET 1.x and 2.0 Application Design 1 August 28th, 2008 11:04 PM
Scrollbar in row of Datagrid Except Header Row Theone84 ASP.NET 2.0 Professional 0 August 11th, 2008 12:10 AM
How to freeze the header row shankhan Classic ASP Databases 1 April 23rd, 2005 02:18 PM
datagrid header row to appear in vertical fashion justshahid General .NET 1 February 7th, 2005 03:25 PM
Creating a Header Row w3s SQL Server DTS 0 June 9th, 2004 10:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.