ASP.NET GridView EditTemplate并找到控件

Gee*_*eth 4 c# asp.net gridview

在GridView中,我们使用了一个编辑按钮.单击编辑按钮后,编辑模板中的控件将与更新按钮显示在同一行中.该行有两个下拉列表控件.

流程:

控制:d1和d2

d1使用sqldatasource进行项目显示:工作正常.

d2使用代码隐藏代码根据d1中的选定值加载项目:不工作

如何在编辑模板中找到控件以显示d2的项目值?

Gee*_*eth 6

我得到了答案.

protected void GridView1_PreRender(object sender, EventArgs e)
 {
  if (this.GridView1.EditIndex != -1)
   {
     Button b = GridView1.Rows[GridView1.EditIndex].FindControl("Button1") as Button;
     if (b != null)
      {
      //do something
      }
   }
 }
Run Code Online (Sandbox Code Playgroud)