控制GridView某一列换行:
在RowDataBound中加上e.Row.Cells[2].Style.Add("word-break", "break-all")
控制所有列换行:
protected void Page_Load(object sender, EventArgs e) { //正常换行 GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal"); //下面这行是自动换行 GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word"); if (!IsPostBack) { bind();//调用数据绑定即可 } }
时间: 2024-10-06 15:51:30