Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have two grid in an ASP.NET page,

I used DIV for scroll bar,for that i used the following query

XML
<div style="height:300px;overflow:auto;display: inline-block;">
                       <asp:GridView ID="grdBillableMonth" runat="server"
                           CssClass="tablestyle" Height="27px">
                           <AlternatingRowStyle CssClass="altrowstyle" />
                           <HeaderStyle CssClass="headerstyle" />
                           <RowStyle CssClass="rowstyle" />
                       </asp:GridView>
 </div>


No the Scroll bar is coming just to end of the grid and resizing according to content of the DIV

That is DIV width is changing automatically with Content.


Now my need is I want the same in the case of Height,
i want DIV height changing according to height of the content,not only that,
i want to set a limit for height.
ie, if height of my grid is 500px..if during binding,say it have only 200px height,the DIV should reduce to 200px height,but when binding,the gird gets more than 500px height,then it shows a scroll bar instead of increasing height


Can anyone help
Posted

1 solution

Use the max-height style.
Here's a quick html block for you to test

XML
<div style="max-height:100px; overflow:scroll; background-color:#aaf;">
<div contenteditable="true">Type more lines here and check</div>
</div>
 
Share this answer
 
Comments
Dalek Dave 11-Mar-11 5:01am    
Exactly what I was going to say!
raju melveetilpurayil 11-Mar-11 6:04am    
good call
Member 15697078 20-Dec-22 5:24am    
well done
Member 15697078 20-Dec-22 5:25am    
its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900