一、使用TemplateColumn:
在Property Builder对话框中,将该列换成Template,关闭对话框。
在DataGrid上右击,选编辑Template中的那一列,然后就可以在里面放入你所要的编辑控件。
二、通过事件ItemCreated完成:
在事件中:
if( e.Item.ItemType == ListItemType.EditItem )
{
    TextBox t = new TextBox();
    t.TextMode = TextMode.MultiLine;
    e.Item.Cells[n].Controls.Clear();
    e.Item.Cells[n].Controls.Add(t);
    // n 为所要的列
}

解决方案 »

  1.   

    read the MSDN magazine article
    "Understanding Templates in ASP.NET"
    http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/cutting0201.aspfor an example
      

  2.   

    我用Template后,倒是出来了一个 DropDownList 

    private void DataGrid_Update(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    //DropDownList DropDownList1 = (DropDownList)e.Item.Cells[9].Controls[0]; //status code
    错误为:无法造型(Cast).
    他几个范例我看不懂呀。
    我该如何在 DataGrid_Update事件里得到那个 DropDownList 的值呢?
    大家再帮帮我好吗?
    我一定给分的
      

  3.   

    我给一段我自己写的程序你看看吧,不过我没有用DropDownList,我想也应该差不多!或许对你有帮助! protected void DataGrid1_Update(object sender,System.Web.UI.WebControls.DataGridCommandEventArgs E)
    {
    int UserID =(int)DataGrid1.DataKeys[(int)E.Item.ItemIndex]; string UserName = ((TextBox)E.Item.Cells[1].Controls[0]).Text;
    string Password=((TextBox)E.Item.Cells[2].Controls[0]).Text;
    string UserType = ((TextBox)E.Item.Cells[3].Controls[0]).Text;
    string UserRole = ((TextBox)E.Item.Cells[4].Controls[0]).Text;
    string UserClass = ((TextBox)E.Item.Cells[5].Controls[0]).Text; string strSql="UPDATE DevUser set UserName='" + UserName + "',Pwd='" + Password + "',UserType='" + UserType + "',UserRole='" + UserRole + "',UserClass='" + UserClass + "' where UserID=" + UserID; string connstr=ConfigurationSettings.AppSettings["OleDbString"];
    OleDbConnection MyConnection=new OleDbConnection(connstr);
    MyConnection.Open(); OleDbCommand myCommand2= new OleDbCommand(strSql, MyConnection);
    myCommand2.CommandType=CommandType.Text;
    myCommand2.ExecuteNonQuery(); DataGrid1.EditItemIndex = -1;
    List();
    }
      

  4.   

    在使用Templates时,给放在其中的DropDownList一个ID.<BR>
    例如:<BR>
    <ItemTemplate><BR>
    <ASP:DropDownList runat="Server" ID="ddlDropDownList"></ASP:DropDownList>
    <ItemTemplate><BR>
    然后使用FindControl.<BR>
    DropDownList ddlDropDownList1=(DropDownList)e.Item.FindControl("ddlDropDownList");
      

  5.   

    非常谢谢 jerryfangsh(傻瓜) 
    给我的简单的方法。
    大家都有
      

  6.   

    谢谢 jerryfangsh(傻瓜) 教给我的简单方法
    昨天我看sdk都看昏了,跳来跳去~新版我连给分都不会了,我再试试