控制绑定到BoundField里的字符串长度

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
 if(e.Item.ItemIndex>-1)
 {
  string tmp = e.Item.Cells[0].Text;
  if(tmp.Length>10)
   e.Item.Cells[0].Text = tmp.Substring(0,10) + "...";
 }
}
posted on 2007-06-04 17:06  Yuxin Yang  阅读(811)  评论(0编辑  收藏  举报