?
Solved

Scrolling and Column Resizing using GridView with AutoGenerated Columns

Posted on 2014-10-29
1
Medium Priority
?
919 Views
Last Modified: 2014-11-07
I am trying to use a GridView control in an ASP.NET/C# project with the AutoGenerateColumns="true".  The data loads into the GridView but I am having two issues.  First issue is that I am unable to get the GridView to scroll horizontally.  It seems that it is just stuffing all the data into the GridView and not expanding.   Second issue is that I am unable to re-size the columns to fit the data. I have feeling that one of these issues may be causing the other.

<asp:Panel ID="Panel2" runat="server" CssClass="panel" Width="100%" ScrollBars="Horizontal">
        <div class="grid" style="width: 100%; overflow: auto;">
            <asp:GridView ID="grdProductionResorces" runat="server" AutoGenerateColumns="True"   OnRowDataBound="grdProductionResorces_OnRowDataBound"
                OnRowCreated="grdProductionResorces_RowCreated"
                BorderStyle="None" BorderWidth="1px" CellPadding="3" BackColor="White" BorderColor="#999999" GridLines="Vertical" CssClass="dataGridTable th">
                <AlternatingRowStyle BackColor="#DCDCDC" />
                <Columns>
                </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#0000A9" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#000065" />
            </asp:GridView>
        </div>
    </asp:Panel>
0
Comment
Question by:WH_Tech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 40415702
I'm not sure but I think you just want to disable text wrapping. You shouldn't need the extra div (I'm guessing you added that for testing). Try this:
    <asp:Panel ID="Panel2" runat="server" CssClass="panel" Width="100%" ScrollBars="Horizontal">
            <asp:GridView ID="grdProductionResorces" runat="server" AutoGenerateColumns="True" OnRowDataBound="grdProductionResorces_OnRowDataBound"
                OnRowCreated="grdProductionResorces_RowCreated"  
                BorderStyle="None" BorderWidth="1px" CellPadding="3" BackColor="White" BorderColor="#999999" GridLines="Vertical" CssClass="dataGridTable th">
                <AlternatingRowStyle BackColor="#DCDCDC" />
                <Columns>
                </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#0000A9" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#000065" />
                <RowStyle Wrap="false" />
            </asp:GridView>
    </asp:Panel>

Open in new window

So the <RowStyle> makes sure the content pushes the cell width to the right. Your panel already supports horizontal scrolling so that should be enough.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question