try<TEXTAREA runat="server" id="mText" 
 cols='<%# DataBinder.Eval(Container.DataItem,"DispLen")%>'
          style="overflow:visible">
     </TEXTAREA>

解决方案 »

  1.   

    to:saucer(思归, MS .NET MVP)
    还是不行,而且这样的话,DispLen值越小,TEXTAREA显示的行数越多。
      

  2.   

    用DIV也是一样的啊。它有好几个属性,可以做到的,同时也是可以编辑的啊
      

  3.   

    我想这样实现,有没有办法给变量A赋值?(我试过A换成一个常数可以的。)
    <asp:TemplateColumn>
      <ItemTemplate>
         <TEXTAREA runat="server" id="mText" 
     cols='<%# DataBinder.Eval(Container.DataItem,"DispLen">'  
              rows='<%# Int(DataBinder.Eval(Container.DataItem,"DispLen")/A)+1%>'
         </TEXTAREA>
      </ItemTemplate>
    </asp:TemplateColumn>
      

  4.   

    my code changes rows automatcially, what is this DispLen?declare A as a class level variable, if you are using codebehind, declare it protected or public, and assign the value before you call DataBind()public A as Integer
    A = 12
    DataGrid1.DataSource = ....
    DataGrid1.DataBind()
      

  5.   

    谢谢大家!
    to:saucersaucer(思归, MS .NET MVP)
    我想根据用户的屏幕分辨率来给A赋值,有没有办法?
      

  6.   

    you don't know 用户的屏幕分辨率 in your server code, unless you are willing to pass the client side properties window.screen.width and window.screen.height back to the server sideI'd suggest a client side solution<script language="javascript">
    function window.onload()
    {
      var txtlist = document.all.tags("TEXTAREA");
      for (var i=0; i < txtlist.length; i++)
        txtlist[i].rows = txtlist[i].cols * 2;
    }
    </script>