DataGrid控件中的EditCommand事件函数为DataGrid_edit(..),请问如何在该函数中修改被编辑行的所有单元呢?比如说在点击编辑按钮的时候程序自动修改“姓名”字段(不是弹出TextBox那样手动修改)
DataGrid的末拌结构为
<Columns>
<asp:BoundColumn DataField="client_name" ReadOnly="True" HeaderText="姓名"></asp:BoundColumn>
<asp:BoundColumn DataField="client_type" ReadOnly="True" HeaderText="户型"></asp:BoundColumn>
<asp:BoundColumn DataField="userid" HeaderText="业务员ID"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="编辑"></asp:EditCommandColumn>

解决方案 »

  1.   

    在EditCommand事件中写修改方法。
    然后在绑定一下
      

  2.   

    比如在点击编辑以前是姓名          户姓       业务员ID  
    刘XX        一室一厅       liwei       编辑点击“编辑”以后变成姓名          户姓       业务员ID  
    隐藏        一室一厅      TextBox      更新 取消
      

  3.   

    private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    e.Item.Cells[1].Text = "abc";
    //this.DataGrid1.EditItemIndex = e.Item.ItemIndex;不要这行
    }
      

  4.   

    事件处理里
    e.Item.FindControl//用模版下
    e.Item.Cells[2].Text
      

  5.   

    需要重绑定也可以,在ItemDataBound中处理:
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.EditItem)
    {
    e.Item.Cells[0].Text = "隐藏";
    }
    }
      

  6.   

    用模板列,不显示的就不加textbox就好了
      

  7.   

    如果不写DataGrid1.DataBind(),可以用e.Item.Cells[1].Text = "abc";改变内容,但TextBox控件不会出现(按两下编辑按钮可以出现),否则TextBox可以出现,但是Cells[1].Text中的内容没有变化,DataGrid1.DataBind()写在e.Item.Cells[1].Text = "abc"行上下效果一样。郁闷