title: Gridview value to a parameter
body: <p>I have a Home.aspx and Home.aspx.cs</p>
  
  <p>I have a gridview in my Home.aspx >>></p>
  
  <pre><code>&lt;asp:GridView ID="DataGridView" runat="server" AutoGenerateColumns="False" ShowFooter="True" 
                          CellPadding="4" ForeColor="#333333" GridLines="None" Height="281px" style="margin-top: 0px" Width="100%" 
                          OnRowCancelingEdit="DataGridView_RowCancelingEdit"  
                          OnRowEditing="DataGridView_RowEditing" OnRowUpdating="DataGridView_RowUpdating" HorizontalAlign="Center" 
                          onrowdatabound="DataGridView_RowDataBound"&gt;
  
                          &lt;AlternatingRowStyle BackColor="Lavender" ForeColor="#284775" /&gt;
  
                          &lt;Columns&gt;
                               &lt;asp:TemplateField&gt;
                                  &lt;HeaderTemplate&gt;Data 1&lt;/HeaderTemplate&gt;
                                  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                                  &lt;ItemTemplate&gt;&lt;asp:Label ID="description" runat="server" Text='&lt;%# Bind("description")%&gt;'&gt;&lt;/asp:Label&gt;&lt;/ItemTemplate&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:DropDownList ID="Editdescription" runat="server"&gt;
                                          &lt;asp:ListItem&gt;--Select--&lt;/asp:ListItem&gt;
                                          &lt;asp:ListItem&gt;SINGLE&lt;/asp:ListItem&gt;
                                          &lt;asp:ListItem&gt;DOUBLE&lt;/asp:ListItem&gt;
                                      &lt;/asp:DropDownList&gt;
                                  &lt;/EditItemTemplate&gt;
                                 &lt;%-- &lt;FooterTemplate&gt;
                                  &lt;/FooterTemplate&gt;--%&gt;
                              &lt;/asp:TemplateField&gt;
  
                              &lt;asp:TemplateField&gt;
                                  &lt;HeaderTemplate&gt;Data 2&lt;/HeaderTemplate&gt;
                                  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                                  &lt;ItemTemplate&gt;&lt;asp:Label ID="pkgcode" runat="server" Text='&lt;%# Bind("pkgcode") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/ItemTemplate&gt;
                                  &lt;EditItemTemplate&gt;&lt;asp:TextBox ID="Editpkgcode" runat="server" Text='&lt;%# Bind("pkgcode") %&gt;'&gt;&lt;/asp:TextBox&gt;&lt;/EditItemTemplate&gt;
                                  &lt;%--&lt;FooterTemplate&gt;&lt;asp:TextBox ID="pkgcode" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;/FooterTemplate&gt;--%&gt;
                              &lt;/asp:TemplateField&gt;
  
                              &lt;asp:TemplateField&gt;
                                  &lt;HeaderTemplate&gt;Data 3&lt;/HeaderTemplate&gt;
                                  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                                  &lt;ItemTemplate&gt;&lt;asp:Label ID="oprcode" runat="server" Text='&lt;%# Bind("oprcode") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/ItemTemplate&gt;
                                  &lt;EditItemTemplate&gt;&lt;asp:TextBox ID="Editoprcode" runat="server" Text='&lt;%# Bind("oprcode") %&gt;' &gt;&lt;/asp:TextBox&gt;&lt;/EditItemTemplate&gt;
                                  &lt;%--&lt;FooterTemplate&gt;&lt;asp:TextBox ID="oprcode" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;/FooterTemplate&gt;--%&gt;
                              &lt;/asp:TemplateField&gt;
  
                          &lt;/Columns&gt;
  
                      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>In my Home.aspx.cs, I have this  >></p>
  
  <pre><code>protected void DataGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
          { } 
  </code></pre>
  
  <p>This is where I plan to update my data from my gridview, but before updating I want to pass the old data to a parameter so user can compare/see the changes he made. For checking purposes so I can see if it really get the data, I put the following inside DataGridView_RowUpdating (and I don't know if it's wrong)>></p>
  
  <pre><code>GridViewRow row = DataGridView.Rows[e.RowIndex];
  string @editpkgcode = (row.FindControl("pkgcode") as Label).Text;
  Literal1.Text = "TEST: " + @editpkgcode;
  </code></pre>
  
  <p>It gives me the error : <strong>NullReferenceException was unhandled by user code</strong></p>