private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
TextBox txt = (TextBox)e.Item.Cells[2].Controls[0];
txt.Width = 120;
txt.Height =40;
txt.TextMode = TextBoxMode.MultiLine;
txt.BackColor = Color.Cyan;
}
}
个人注释:只有在DataGrid1_ItemDataBound事件里指定有效,在DataGrid1_UpdateCommand事件里无效
在DataGrid1_UpdateCommand事件里取值
string val = ((TextBox)e.Item.Cells[2].Controls[0]).Text;