ItemDataBound事件怎么无效?
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.DataSetIndex != -1)
{
int len=e.Item.Cells[1].Text.Length;
if(len> 6)
{
e.Item.Cells[1].Text=e.Item.Cells[1].Text.Substring(0,6)+ "... ";
}
}
}
想达到截断字符串长度的目的,但好像没有被执行;事件丢失?该怎么办?
------解决方案-------------------- <asp:DataGrid ID =grid runat=server OnItemDataBound= "grid_ItemDataBound " > </asp:DataGrid>
------解决方案--------------------楼上解了