大于20的不显示吗?那你就在sql理截取好了。

解决方案 »

  1.   

    private void Datggeneral_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if ( e.Item.Cells[0].Text.Length > 10)
    {
    e.Item.Cells[0].ToolTip = e.Item.Cells[0].Text;
    e.Item.Cells[0].Text = e.Item.Cells[0].Text.Substring( 0,10) + "...";
    }
    }
      

  2.   

    在DataGrid_ItemDataBound事件中
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    if ( e.Item.Cells[0].Text.Length > 20)
    {
    e.Item.Cells[0].Text = e.Item.Cells[0].Text.Substring( 0,20) + "...";
    }
    }
      

  3.   

    请问winwang168(无名)  e.Item.Cells[0].Text这个值为什么总是空值啊!为什么穿不进来啊!
      

  4.   

    e.Item.Cells[0].Text = e.Item.Cells[0].Text.Substring( 0,20) + "...";后面的
    省略符号是什么啊?谢谢
      

  5.   

    请问winwang168(无名)  e.Item.Cells[0].Text这个值为什么总是空值啊!为什么穿不进来啊!
    你要先做DataGrid的数据绑定,才会执行ItemDataBound的动作。e.Item.Cells[0].Text = e.Item.Cells[0].Text.Substring( 0,20) + "...";后面的
    省略符号是什么啊?谢谢
    省略号是为了让你显示的字好看一些,表示还没显示完,用省略号代替。
      

  6.   

    省略符号??就是省略符号啊,比如本来是"周末散分,心情郁闷,希望能过个轻松的周末,也祝大家周末愉快! " 那么长一句,用public string Substring(int, int);得到结果就是类似"周末散分,心情郁闷,希望能过个轻松的周末…"这样的,(也可以用Remove方法)
      

  7.   

    <asp:templatecolumn>
    <itemstyle width="200px"></itemstyle>
    <itemtemplate>
    </itemtemplate>
    </asp:templatecolumn>即可
      

  8.   

    在datagrid 属性里面设置 列的宽度..