A code written in the TEXTBOX width (other attribute also line) in the DataGrid.
C #, add some judgment, or control the properties of other controls, such as Listbox: D
Private void Dgimage_ItemDatabase (Object Sender, System.Web.ui.WebControls.DataGriditeMeventArgs E)
{
System.Web.ui.WebControls.TextBox TB;
Int intlength;
IF (E.Item.ItemType == ListItemType.editItem)
{
// Cycle all units
For (INT i = 0; I { // Is there a control within the unit IF (E.Item.cells [i] .controls.count> 0) { // If it is a TextBox control IF (E.Item.cells [i] .controls [0] .gettype (). Tostring () == "System.Web.ui.WebControls.TextBox") { TB = (TextBox) E.Item.cells [i] .controls [0]; Intlength = 0; Intlength = Tb.Text.Length; IntLength = intlength * 7; IF (intlength == 0) intlength = 20; Tb.width = intlength; Tb.cssclass = "datagridtextbox"; // Your CSS style sheet name // You can set other properties of TextBox } } } } }