DataGrid删除对话框 & 限制编辑模试TextBox长度
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
////进入编辑模试限制TextBox的width////
e.Item.Cells[4].Attributes.Add("onClick","return confirm('你确定要删除这一项吗?');");
if(e.Item.ItemType == ListItemType.EditItem)
{
if(e.Item.Controls[1].Controls[0].GetType().ToString() == "System.Web.UI.WebControls.TextBox")
{
TextBox tb = (TextBox)e.Item.Controls[1].Controls[0];
tb.Width = Unit.Parse("80px");
tb.CssClass = "textbox";
tb.Text = Server.HtmlDecode(tb.Text);
}
if(e.Item.Controls[2].Controls[0].GetType().ToString() == "System.Web.UI.WebControls.TextBox")
{
TextBox tb = (TextBox)e.Item.Controls[2].Controls[0];
tb.Width = Unit.Parse("250px");
tb.CssClass = "textbox";
tb.Text = Server.HtmlDecode(tb.Text);
}
}
}