如何使最大大小设置为包含DIV的GridView [英] How to make a GridView with maxmimum size set to the containing DIV
本文介绍了如何使最大大小设置为包含DIV的GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据包含它的DIV来修复GridView的大小。我改变了每一个可能的属性,但在gridview没有任何变化。以下是标记:
I want to fix the size of a GridView depending on the DIV containing it. I changed every possible attribute but nothing changes in the gridview. Here is the markup:
<table cellpadding="0" cellspacing="0" width="100%" style="height:100%">
<tr>
<td>
<div style="width: 500px">
<asp:GridView ID="GridView1" runat="server"
AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="QuotationSQLDS"
onrowdatabound="GridView1_RowDataBound"
ForeColor="Black" Width="100%">
<HeaderStyle HorizontalAlign="Center" Font-Size="8pt" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id"
ReadOnly="True" SortExpression="Id"/>
<asp:BoundField DataField="description"
HeaderText="Description"
SortExpression="description" />
</Columns>
</asp:GridView>
</div>
</td>
</tr>
请帮我,因为我要踢我的笔记本电脑。感谢
Please help me out because I am about to kick my laptop. Thanks
推荐答案
尝试这样做
gridview
并包含 div
<div class="container" style="width: 500px">
<asp:GridView ID="GridView1" runat="server" CssClass="gvData"
AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="QuotationSQLDS"
onrowdatabound="GridView1_RowDataBound"
ForeColor="Black">
<HeaderStyle HorizontalAlign="Center" Font-Size="8pt" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id"
ReadOnly="True" SortExpression="Id"/>
<asp:BoundField DataField="description"
HeaderText="Description"
SortExpression="description" />
</Columns>
</asp:GridView>
</div>
并使用 jQuery ,并执行如下操作:
And use jQuery and do something like this:
$(document).ready(function () {
var height = $('.container').height();
$('.gvData').height(height);
});
和 .css
p>
and in your .css
:
.container{height:auto; float:left;overflow:hidden;display:block;}
这篇关于如何使最大大小设置为包含DIV的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文