1.如下图所示的一个Gridview 控件,当点击编辑时出现图2: 图1 图2 当我们点击[更新]按钮时获取方框和下拉菜单的值的方法: DropDownList dl = GridView1.Rows[e.RowIndex].Cells[2].Controls[1] as DropDownList; TextBox tb = GridView1.Rows[e.RowIndex].Cells[1].Controls[1] as TextBox; int id = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); int cpid = Int32.Parse(dl.SelectedValue); new Hntjxh.BLL.Category().UpdateCategory(id, tb.Text, cpid); GridView1.EditIndex = -1; BindCategoryTableValue(); 注意”GridView1.Rows[e.RowIndex].Cells[1].Controls[1]“这一行,要取Controls[1]而不是0,通过试验得知Controls[0]是一个System.Web.UI.Liter alControl类型的控件,Controls[1]才是我们想要的控件!