Datagrid为什么不自动换行显

datagrid中某一列绑定一数据库字段,当该字段内容很多时,Datagrid为什么不自动换行显示,在DataGrid中加入下面样式,就换行了.
style="table-layout:fixed;word-break:break-all;word-wrap:break-word;"

 DataGrid1.HeaderStyle.Wrap= true;
        DataGrid1.ItemStyle.Wrap=true;

//当项被数据绑定到 DataGrid 控件后,将引发 ItemDataBound 事件
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff';this.style.color='buttontext';this.style.cursor='default';");
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color=''");
        }
        if (e.Item.ItemIndex != -1)
        {
            e.Item.Cells[0].Text = (this.DataGrid1.CurrentPageIndex * this.DataGrid1.PageSize + e.Item.ItemIndex + 1).ToString();
        }
        string show="名称:\n"+e.Item.Cells[1].Text.ToString() + "\n" + "内容:\n"+e.Item.Cells[2].Text.ToString();

        for (int i = 0; i < show.Length;i+=10)
        {
            show=show.Insert(i, "\n");
        }
        //Response.Write(show);
        //e.Item.ToolTip = show;
        //e.Item.Attributes.Add("title", show);
        e.Item.Cells[1].Attributes.Add("title", show);
        //e.Item.tit
        //e.Item.ToolTip = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

转载于:https://www.cnblogs.com/draeag/archive/2007/09/15/894061.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值