1.protected void GridView1_RowDataBound(object sender,GridViewRowEvebtArg e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
for(int i = 0; i < GridView1.Columns.Count; i++)
{
GridView1.Columns[0].ItemStyle.Width = 80;
GridView1.Columns[1].ItemStyle.Width = 60;
}
}
}
2.在ASP.net的UI页面进行设置(那天在房管系统中,竟然没起作用,不知道为什么)
gridview————点击右上角的小三角号————编辑列————选中你要编辑的列————
在右面的对话框的最下面倒数4行(样式)————分别是什么ControlStyle , FooterStyle,
HederStyle, ItemStyle 选ControlStyle或ItemStyle行展开他————设置Width的数值 如100px
3.在RowCreated事件中添加(没用过这个方法)
e.Row.Cell[6].Attributes.Add("style", "word-break:break=all : word-wrap:break-word");
ASP.NET GridView 列宽设置
本文介绍三种在ASP.NET中调整GridView列宽的方法:通过RowDataBound事件、UI页面编辑列设置宽度及使用RowCreated事件调整单元格样式。
4805

被折叠的 条评论
为什么被折叠?



