I have a GridView as below

```
<asp:GridView ID="gvChain" runat="server" Font-Size="Small" CellPadding="3" CellSpacing="1" GridLines="None" AutoGenerateColumns="False">
  <headerstyle backcolor="#CCCCCC" />
  <columns>
  <asp:BoundField DataField="Department" HeaderText="Department" />
  <asp:TemplateField HeaderText="Manager Level 1">
    <ItemTemplate>
      <asp:Label ID="lblManager1" runat="server" Text=""></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
      <asp:DropDownList ID="cbManager1" runat="server"/>
    </EditItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Manager Level 2">
    <ItemTemplate>
      <asp:Label ID="lblManager2" runat="server"/>
    </ItemTemplate>
    <EditItemTemplate>
      <asp:DropDownList ID="cbManager2" runat="server"/>
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ShowEditButton="True">
      <ControlStyle ForeColor="#009EDD" />
    </asp:CommandField>
  </columns>
</asp:GridView>

```

The BoundField 'Department' is being populated in the Page\_Load as below which works fine and populates the GridView with a list of departments.

```
Dim dhandler As DepartmentHandler = New DepartmentHandler
Dim depts As New List(Of Department)

depts = dhandler.GetDepartmentList

gvChain.DataSource = depts
gvChain.DataBind()

```

I am then populating the ItemTemplates of the TemplateFields in the RowDAtaBound event as below. this is also working fine.

```
If e.Row.RowType = DataControlRowType.DataRow Then
  Dim lblManager1 As Label = DirectCast(e.Row.FindControl("lblManager1"), Label)
  Dim lblManager2 As Label = DirectCast(e.Row.FindControl("lblManager2"), Label)

  Dim eHandler As EmployeeHandler = New EmployeeHandler
  Dim deptCell As TableCell = e.Row.Cells(0)
  Dim dept As Department = New Department
  dept.Department = deptCell.Text
  Dim mgr1 As Manager = eHandler.getManager1(dept)
  Dim mgr2 As Manager = eHandler.getManager2(dept)

  lblManager1.Text = mgr1.Name
  lblManager2.Text = mgr2.Name
End If

```

What I now want to achieve is when clicking on the 'Edit' field of a row on the GridView, populate cbManager1 and cbManager2 with a list of Managers and set the SelectedValue of each DDL to the same values as I am retrieving in the item template. I can get the data with the below code in the RowEditing event of the GridView:

```
' Get the list of managers
Dim mgrs As New List(Of Manager)
mgrs = eHandler.GetManagerList

' Get the department name from the BoundField
Dim deptCell As TableCell = gvChain.Rows(e.NewEditIndex).Cells(0)
Dim dept As Department = New Department
dept.Department = deptCell.Text

' Pass the department name to the getManager1/2 functions to return the correct manager for that department
Dim mgr1 As Manager = eHandler.getManager1(dept)
Dim mgr2 As Manager = eHandler.getManager2(dept)

```

I have set breakpoints to check the data is being returned from the functions and the data is there as expected but where I am stuck is getting a reference on the DDLs in the EditItemTemplate so I can databind them and set the SelectedValue.

I have tried the below but this is giving a NullReference Exception:

```
Dim cbManager1 As DropDownList = TryCast(gvChain.Rows(e.NewEditIndex).FindControl("cbManager1"), DropDownList)
Dim cbManager2 As DropDownList = TryCast(gvChain.Rows(e.NewEditIndex).FindControl("cbManager2"), DropDownList)

```