gridview的固定宽度和百分比宽度问题
gridview生成的两个table, 第一个有5列,宽度是container的100%, 第二个有两列,宽度是40%。两个table在最左边都加了一个带checkbox的列,宽度是20px。第一个table的显示效果是我需要的,但是第二个怎么才能让它的col1, col2和第一个的col1,col2对齐呢?
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
<style type="text/css">
.gvSelect
{
width:20px;
background-color:#cccccc;
}
.gvColumn
{
text-align:left;
width:20%;
background-color:#cccccc;
}
</style>
</head>
<body>
<form name="form1">
<div class="container">
<div style="width:100%">
<table cellspacing="0" rules="all" border="1" style="border-color:#E6E6E6;width:100%;border-collapse:collapse;">
<tr>
<th class="gvSelect" scope="col"><input type="checkbox"/></th>
<th class="gvColumn" scope="col">col 1</th>
<th class="gvColumn" scope="col">col 2</th>
<th class="gvColumn" scope="col">col 3</th>
<th class="gvColumn" scope="col">col 4</th>
<th class="gvColumn" scope="col">col 5</th>
</tr>
<tr style="height:20px;">
<td><input type="checkbox" /></td>
<td>row 1</td>
<td>data</td>
<td colspan="2">data</td>
<td>data</td>
</tr>
<tr style="height:20px;">
<td><input type="checkbox" /></td>
<td>row 2</td>
<td>data</td>
<td colspan="2">data</td>
<td>data</td>
</tr>
</table>
</div>
<div style="margin-top:10px; width:100%">
<div style="width:40%">
<table cellspacing="0" rules="all" border="1" style="border-color:#E6E6E6;width:100%;border-collapse:collapse;">
<tr>
<th class="gvSelect" scope="col"><input type="checkbox"/></th>
<th class="gvColumn" scope="col">col 1</th>
<th class="gvColumn" scope="col">col 2</th>
</tr>
<tr style="height:20px;">
<td><input type="checkbox" /></td>
<td>data</td>
<td>data</td>
</tr>
</table>
</div>
</div>
</div>
</form>
</body>
</html>
...全文
相关推荐
asp.net gridview列宽固定的几种方法介绍
**通过HeaderStyle设置百分比宽度**: 你还可以根据屏幕大小设置列的相对宽度。
在ASP.NET中优化GridView显示超长字符的方法
GridView是一个广泛使用的ASP.NET服务器控件,它允许开发者在Web应用程序中以表格形式展示数据。通过其强大的配置选项和事件驱动模型,开发者能够实现数据的动态显示、编辑和分页等复杂操作。RowDataBound事件在GridView控件中的数据绑定过程中触发,每当控件中的数据行与数据源绑定时就会发生。这个事件可以用来自定义数据行的内容或样式,例如,可以在行绑定后立即修改单元格中的数据或格式化文本。在ASP.NET中,GridView控件提供了一种自定义列的方式来展示数据。使用。
gridview使用技巧、gridview使用大全、gridview常用问题、gridview常用方法
- 格式问题:使用TemplateField定制字段格式,如日期、货币等。 - 宽度调整:使用AutoSizeMode属性控制列宽,或通过CSS样式设置固定宽度。6.
关于中gridview 字符串截取的方法
具体操作如下:- 设置一个类名(如.listover150),这个类将应用到那些需要固定宽度显示的单元格。- 通过CSS属性“width”设定固定宽度,例如150像素。
GridView平均分配布局
使用`MeasureSpec`提供的模式和大小,我们可以确保所有视图具有相同的宽度和高度,从而实现平均分配。例如,可以设置固定宽度和高度,或者根据屏幕尺寸动态计算。3.


