ItemDataBound事件中
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string str = e.Item.Cells[0].Text;
e.Item.Cells[0].Height = Int32.Parse(str);
}

解决方案 »

  1.   

    来晚一步
    这个方法我在 DataSet 中用过
    DataGrid中没有用过
      

  2.   

    Question: How do I change the width of the Textboxes created in edit-mode of my Datagrid? Updated! Answer: Here's an example of how to set the width of an edit Textbox in the EditItemTemplate of your TemplateColumn: <asp:DataGrid id="YourID" runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn HeaderText="Sample Column">
      <ItemTemplate>
        <%#Container.DataItem("AColumnName")%>
      </ItemTemplate>
      <EditItemTemplate>
        <asp:Textbox runat="server" width="600" maxlength="600"/>
      </EditItemTemplate>
    </asp:TemplateColumn>And for a BoundColumn, you can modify the width just before the Datagrid is rendered: Private Sub DataGrid1_PreRender(s As Object, e As EventArgs)
    If DataGrid1.EditItemIndex > -1 Then
      Dim tbx As TextBox
      tbx = CType(DataGrid1.Items(DataGrid1.EditItemIndex).Cells(0).Controls(0), TextBox)
      tbx.Width = Unit.Parse("1cm")
    End If
    End Sub来源 
    http://datagridgirl.com/faq.aspx
      

  3.   

    ItemDataBound事件中textbox1.Width = System.Web.UI.WebControls.Unit.Parse(textbox1.Text);