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);
     }     
    }

  }

posted @ 2004-05-13 14:23  MHL  阅读(1536)  评论(0编辑  收藏  举报