控制绑定到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) + "...";
 }
}

你可能感兴趣的:(Field)