A code written in the TEXTBOX width (other attribute also line) in the DataGrid. C #, the more certain judgment, control may also control other attributes, such as ListBox: Dprivate void dgImage_ItemDataBound (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 0) {// If it is the 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 Table Name // You can set TextBox Other Properties}}}}}