Asp.net 如何在gridview的行编辑事件中获取列值

Asp.net 如何在gridview的行编辑事件中获取列值,asp.net,Asp.net,这是我在rowdatabound事件中的编辑代码 if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { DropDownList dl = (DropDownList)e.Row.FindContro

这是我在rowdatabound事件中的编辑代码

if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                {
                    DropDownList dl = (DropDownList)e.Row.FindControl("Sectionname");
                    comp.MEDIUM = Convert.ToString(e.Row.FindControl("Medium"));
                    comp.CLASSNAME = Convert.ToString(e.Row.FindControl("ClassName"));
                    comp.ACADAMICYEAR = Convert.ToString(e.Row.FindControl("AcademicYear"));
                    DataTable worktype = inter.bindsectionforgird(comp);
                    dl.DataSource = worktype;
                    dl.DataTextField = "SectionName";
                    dl.DataValueField = "SectionId";
                    dl.DataBind();
                }
            }

我仍然无法获取这些字段的值。

我建议您在
RowDataBound
事件中编写代码

  void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
 {

if(e.Row.RowType == DataControlRowType.DataRow)
   {
       // Write your code here           
   }

 }
您可以找到网格的列,如下所示

e.Row.FindControl("yourControlID")
您可以在



您是在什么情况下编写此代码的?是的。我编写了代码行绑定事件。但仍然无法获取gridview绑定字段的值。首先,我编写了这些代码行编辑。然后将代码更改为rowdataboud事件。