0

I am embedding a gridview inside of a panel like this, which works as it should, but I sometimes return a great deal of information and would like to be able to add a horizontal scroll bar to the top as well, can someone assist??

<asp:Panel ID="panel1" runat="server" ScrollBars="Both" style="overflow:scroll">
<asp:GridView ID="grid1" runat="server" Visible="True" AutoGenerateColumns="false" 
        ShowFooter="true" Width="16px" Height="120px" >/>
        <columns>

        </columns>
    </asp:GridView>
</asp:Panel>

EDIT

I am trying to use the option from the link you provided below, but my grid width is way to small. I think I have it set properly in the syntax tho?

<div class="wrapper1">
    <div class="wrapper2">
        <asp:GridView ID="grid1" runat="server" Visible="True" AutoGenerateColumns="false" 
            ShowFooter="true" Width="10000pxpx" Height="3000px" >/>
            <columns>

            </columns>
        </asp:GridView>
    </div>
</div>

<style type="text/css">
    .wrapper1, .wrapper2{width: 300px; border: none 0px RED; overflow-x: scroll; overflow-y:hidden;}
    .wrapper1{height: 200px; }
    .wrapper2{height: 200px; }
    .div1 {width:10000px; height: 200px; }
    .div2 {width:10000px; height: 200px; background-color: #88FF88; overflow: auto;}
</style>

Also, adding in the extra <div> tag throws the grid further down on the page than what I need it to be.

1 Answer 1

0

You can try removing your panel and go with a div instead.

<div style="overflow-x:auto;width:800px">
   GridView here
</div>

overflow-x:auto will produce a horizontal scrollbar only if the GridView's width is greater than 800px.

5
  • that adds a horizontal scrollbar to the bottom, how can I add one to the top as well? Jan 11, 2016 at 3:19
  • Not so easy to do without a bit of extra coding... Have a look at this answer stackoverflow.com/questions/3934271/…
    – Scotty
    Jan 11, 2016 at 3:27
  • trying to follow one of the options in your link, but grid width is not correct, can you take a look? Jan 11, 2016 at 14:22
  • Try fixing your width definition, it's currently 1000pxpx
    – Scotty
    Jan 11, 2016 at 20:18
  • How did you go? Any luck?
    – Scotty
    Jan 18, 2016 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.