So i have a dropdownlist that appears when my gridview is in edit mode. The problem is that when i press the update button, I get a null reference error. This is because for some reason the update event claims that the dropdownlist does not exist within the gridview. The same can be said when i look at the markup. However, when i run the page and press the edit button my dropdownlist comes up with no problems. Can anyone tell me why this is the case?

This is what i have so far for the codebehind with the update event:

```
        protected void GridViewHolder_Updating(object sender, GridViewUpdateEventArgs e) 
    {

        int machineid1;
        string machineid;
        string machineTypeid;
        string machineModelid;

        GridViewRow row = (GridViewRow)GridViewHolder.Rows[e.RowIndex];

        machineid = ((Label)(row.Cells[0].Controls[1])).Text;
        machineid1 = Convert.ToInt32(machineid); 
        machineTypeid = ((DropDownList)(row.Cells[3].FindControl("MachineTypeDropDown"))).SelectedValue;
        machineModelid = ((DropDownList)(row.Cells[4].Controls[1])).SelectedValue;

        //inputsService.UpdateMachineTypes(machineid, machineTypeid);
        //inputsService.UpdateMachineModels(machineid, machineModelid);

    }

```

below you will find the mark up and the .ascx gridview markup:

viewsource:

```
<th scope="col">Site Name</th><th scope="col">Machine Name</th><th scope="col">Machine Type</th><th scope="col">Machine Model</th><th scope="col">&nbsp;</th>

                        </tr><tr align="center" style="background-color:Transparent;">

                            <td>SACRAMENTO</td><td>DC04</td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl02_MachineTypeLabel">empty</span>                            

                    </td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl02_MachineModelLabel">empty</span>                            

                    </td><td align="center"><input type="button" value="Edit" onclick="javascript:__doPostBack('AssignMachineTypesAndModels_userControl$GridViewHolder','Edit$0')" /></td>

                        </tr><tr align="center" style="background-color:Transparent;">

                            <td>SACRAMENTO</td><td>DC1</td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl03_MachineTypeLabel">empty</span>                            

                    </td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl03_MachineModelLabel">empty</span>                            

                    </td><td align="center"><input type="button" value="Edit" onclick="javascript:__doPostBack('AssignMachineTypesAndModels_userControl$GridViewHolder','Edit$1')" /></td>

                        </tr><tr align="center" style="background-color:Transparent;">

                            <td>SACRAMENTO</td><td>MPS01</td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl04_MachineTypeLabel">empty</span>                            

                    </td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl04_MachineModelLabel">empty</span>                            

                    </td><td align="center"><input type="button" value="Edit" onclick="javascript:__doPostBack('AssignMachineTypesAndModels_userControl$GridViewHolder','Edit$2')" /></td>

                        </tr><tr align="center" style="background-color:Transparent;">

                            <td>SACRAMENTO</td><td>MSE01</td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl05_MachineTypeLabel">empty</span>                            

                    </td><td>

                        <span id="AssignMachineTypesAndModels_userControl_GridViewHolder_ctl05_MachineModelLabel">empty</span>                            

                    </td><td align="center"><input type="button" value="Edit" onclick="javascript:__doPostBack('AssignMachineTypesAndModels_userControl$GridViewHolder','Edit$3')" /></td>

```

gridview markup:

```
 <Columns>
                <asp:TemplateField HeaderText="ID" 
                                   SortExpression="ID" 
                                   Visible="False">
                    <ItemTemplate>
                        <asp:Label ID="Label1" 
                                   runat="server" 
                                   Text='<%# Bind("ID") %>'
                                   Visible="false">
                        </asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="SiteName" 
                                HeaderText="Site Name" 
                                SortExpression="SiteName"
                                ReadOnly="true" />
                <asp:BoundField DataField="Name" 
                                HeaderText="Machine Name" 
                                ReadOnly="true" 
                                SortExpression="Name" />
                <asp:TemplateField HeaderText="Machine Type" 
                                   SortExpression="MachineType">
                    <ItemTemplate>
                        <asp:Label ID="MachineTypeLabel" 
                                   runat="server" 
                                   Text='<%# Bind("MachineType") %>'>
                        </asp:Label>                            
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="MachineTypeDropDown" 
                                          runat="server" 
                                          AppendDataBoundItems="True"                                                
                                          Height="21px" 
                                          Width="217px" 
                                          DataSourceID="GetMachineType" 
                                          DataTextField="Name" 
                                          DataValueField="ID">
                            <asp:ListItem Enabled="true" 
                                          Text="Select a Machine Type." 
                                          Value="NULL">
                            </asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Machine Model" SortExpression="MachineModel">
                    <ItemTemplate>
                        <asp:Label ID="MachineModelLabel" 
                                   runat="server" 
                                   Text='<%# Bind("MachineModel") %>'>
                        </asp:Label>                            
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="MachineModelDropDown" 
                                          runat="server" 
                                          AppendDataBoundItems="True"                                                
                                          Height="21px" Width="217px" 
                                          DataSourceID="GetMachineModel" 
                                          DataTextField="Name" 
                                          DataValueField="ID">
                            <asp:ListItem Enabled="true" 
                                          Text="Select a Machine Model." 
                                          Value="NULL">
                            </asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ButtonType="Button" 
                                  ShowEditButton="True"
                                  CausesValidation="false" >
                    <ItemStyle HorizontalAlign="Center" 
                               Wrap="True" />
                </asp:CommandField>
            </Columns>

```

Any help or suggestions are greatly appreciated.

Thank you