在aspx文件里面怎么定义datagrid属性,使得datagrid不换行?这里有提到使它不换行的方法,但是不适合我:
http://blog.csdn.net/net_lover/archive/2004/06/27/27689.aspx
//对于没有数字的内容,下面这行完全满足要求,但加了数字就不行,必须调用OnItemDataBound
  ItemsGrid.Attributes.Add("style","word-break:keep-all;word-wrap:normal");
 
  //下面这行是自动换行
  //ItemsGrid.Attributes.Add("style","word-break:break-all;word-wrap:break-word");
 我只能够修改aspx文件来达到我的目的。该怎么办?我尝试想这样指定属性:
<asp:ButtonColumn Text="删除" CommandName="Delete" ItemStyle="word-break:keep-all;word-wrap:normal"></asp:ButtonColumn>
结果报错:
分析器错误信息: “ItemStyle”属性是只读的,不能进行设置。help

解决方案 »

  1.   

    把你的
    <asp:ButtonColumn Text="删除" CommandName="Delete" ItemStyle="word-break:keep-all;word-wrap:normal"></asp:ButtonColumn>
    加上<ItemStyle...>标记:
    <asp:ButtonColumn Text="删除" CommandName="Delete" >
       <ItemStyle Wrap="False"></ItemStyle>
    </asp:ButtonColumn>
      

  2.   

    <ItemStyle Wrap="False"></ItemStyle>
      

  3.   

    thans you.我测试下就上来结帖子
      

  4.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=A27CA611-2DE7-432D-8DBC-1512CEFDAA53
      

  5.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if ( e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem )
    {
    for(int i=0;i<10;i++)//i<列数
    e.Item.Cells[i].Attributes.Add("nowrap","true");
    }
      

  6.   

    <ItemStyle Wrap="False"></ItemStyle>
      

  7.   

    这里看一下:
    http://dotnet.aspx.cc/ShowDetail.aspx?id=A27CA611-2DE7-432D-8DBC-1512CEFDAA53