e.Item.Cells[0].Width = 100;
--->>>>
你应该修改产生的文本框长度
TextBox tb =(TextBox)e.Item.Cells[0].Controls[0]
tb.width=Unit.Pixel(100)

解决方案 »

  1.   

    可以在.aspx文件中控制
    <asp:BoundColumn HeaderText="aa" DataField="aa">
    <ItemStyle Width=200></ItemStyle>
    </asp:BoundColumn>
      

  2.   

    再有你修改的时候,在templatecolumn中指定textbox的宽度 <asp:TextBox Runat=server ID="txt" Width=200 Text='<%#DataBinder.Eval(Container,"DataItem.nr")%>'>
    </asp:TextBox>
      

  3.   

    <asp:BoundColumn DataField="CustomerName" HeaderText="CustomerName">
    <ItemStyle Width="400px"></ItemStyle>
    </asp:BoundColumn>
      

  4.   

    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"Width="575px" Height="168px"></asp:DataGrid>的换行修改成 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"Width="575px" Height="168px" style="word-break:break-all"></asp:DataGrid>
    然后制定各个列的宽度,这样的效果好的多,我就是那样做的!!
      

  5.   

    可以在.aspx文件中控制
    <asp:BoundColumn HeaderText="aa" DataField="aa">
    <ItemStyle Width=200></ItemStyle>
    </asp:BoundColumn>
    --->To houlinghouling(冰雪寒霜) 以上方法也试过,没有用。To acewang(大灰很) :
       TextBox tb =(TextBox)e.Item.Cells[0].Controls[0]
       出现 “指定参数超过有效值范围的错误!参数index”
      

  6.   

    To  yangyangbeibei(针眼儿) 谢谢! 可以了!
      

  7.   

    解释一些为什么这样,
    datagrid默认的换行有3种方式,1为默认
    2为 word-break:break-all符合亚洲习惯的换行
    3为 word-break:brdak-keap就是不换行的意思(忘记了)
    msdn的帮助里有的写
      

  8.   

    3为word-break:keap-allDoes not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.