您的位置:首页 > 其它

GridView自动生成列时,利用DIV控制显示长宽 控件数据行和表头文字不换行

2016-12-29 00:00 155 查看
<div style="width:600px; height:300px; overflow-x:auto; ">
<asp:GridView ID="GridView1" runat="server" ClientIDMode="Static" AutoGenerateColumns="True"
CssClass="gvCss" onrowcreated="GridView1_RowCreated">
<RowStyle HorizontalAlign="Center" />
<HeaderStyle CssClass="gvCss head" />
</asp:GridView>
</div>


protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
TableCellCollection cells1 = e.Row.Cells;
for (int i = 0; i < cells1.Count; i++)
{
cells1[i].Wrap = false;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐