title: Error: system.data.dataexception cannot set NAME
body: <p>I have a page with two gridview; one is inside the modal pop up (<code>grdEmpName</code>) and the other is in the page (<code>gvUser</code>). Now, when the user select search button the modal pop up extender will pop up and then search employees. When the user select someone, the selected data should display to the textbox in the another gridview (<code>gvUser</code>).</p>
  
  <p>Everything is working up to selection in modal pop up extender gridview (<code>grdEmpName</code>) but when I select no data pass to the other gridview. (<code>gvUser</code>). I need to display the selected data in the textbox.</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;asp:GridView ID="gvUser" runat="server" Width="1024px"
                  PageSize="10"  
                  AutoGenerateColumns = "False"  
                  AllowSorting="true"  
                  AllowPaging="true"  
                  ShowFooter="True" 
                  OnSorting="gvUser_Sorting"  
                  OnPageIndexChanging="gvUser_PageIndexChanging"  
                  OnRowCreated="gvUser_RowCreated"
                  CssClass="Grid"  
                  AlternatingRowStyle-CssClass="alt" 
                  PagerStyle-CssClass="pgr"  
                  FooterStyle-HorizontalAlign="center" &gt; 
                  &lt;PagerSettings Mode="NumericFirstLast" PageButtonCount="5" FirstPageImageUrl="~/images/gridview/first_16x16.png" LastPageImageUrl="~/images/gridview/last_16x16.png"  /&gt;
                  &lt;Columns&gt;
                      &lt;asp:TemplateField&gt; 
                          &lt;ItemTemplate &gt;      
                              &lt;asp:ImageButton ID="ibtnEdit" runat="server"  ImageUrl="~/images/gridview/file_edit_24x24.png"  title = "Edit"  _CommandArgument='&lt;%# Eval("USR_ID") &amp; "|Edit|" &amp;  CType(Container,GridViewRow).RowIndex &amp; "|-" %&gt;'  /&gt;
                              &lt;asp:ImageButton ID="ibtnUpdate" runat="server" ImageUrl="~/images/gridview/file_save_24x24.png" visible="false" title="Update" _CommandArgument='&lt;%# Eval("USR_ID") &amp; "|Update|" &amp;  CType(Container,GridViewRow).RowIndex  &amp; "|-" %&gt;' /&gt;  
                              &lt;asp:ImageButton ID="ibtnCancel" runat="server" ImageUrl="~/images/gridview/file_cancel_24x24.png" Visible="false" title="Cancel" _CommandArgument='&lt;%# Eval("USR_ID")&amp; "|Cancel|" &amp;  CType(Container,GridViewRow).RowIndex &amp; "|-" %&gt;'  /&gt; 
                              &lt;asp:ImageButton ID="ibtnDelete" runat="server" ImageUrl="~/images/gridview/file_delete_24x24.png" title="Delete"  _CommandArgument='&lt;%# Eval("USR_ID")&amp; "|Delete|" &amp;  CType(Container,GridViewRow).RowIndex &amp; "|" &amp; Eval("USR_IDNTY") %&gt;'   /&gt; 
                              &lt;asp:ImageButton ID="btnSearchUser" runat="server" ImageUrl="~/images/gridview/file_search_24x24.png" title="Search" _CommandArgument= "btnSearchUser" OnClick = "btnSearchUser_Click"  /&gt; 
                          &lt;/ItemTemplate&gt; 
  
                          &lt;FooterTemplate&gt;
                              &lt;asp:ImageButton ID="ibtnAdd" runat="server" ImageUrl="~/images/gridview/file_add_24x24.png" title="Add" _CommandArgument='&lt;%# Eval("USR_ID") &amp; "|Add|" &amp;  CType(Container,GridViewRow).RowIndex &amp; "|-" %&gt;' /&gt; 
  
                          &lt;/FooterTemplate&gt;
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle Wrap="False" Width="50px"  /&gt;            
                      &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="User Identity" visible ="false" &gt;
  
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblUSR_IDNTY" runat="server" Text='&lt;%# Bind("USR_IDNTY")%&gt;' /&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;
                              &lt;asp:Label ID="lblUSR_IDNTY" runat="server" Width="95%"  Text='&lt;%# Bind("USR_IDNTY")%&gt;' /&gt;
                          &lt;/EditItemTemplate&gt;  
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle Wrap="False" /&gt;
                   &lt;/asp:TemplateField&gt;                        
  
                      &lt;asp:TemplateField HeaderText="User ID" SortExpression="USR_ID"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblUSR_ID" runat="server" Text='&lt;%# Bind("USR_ID")%&gt;' /&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;
                              &lt;asp:Label ID="txtUSR_ID" runat="server" Width="95%"  Text='&lt;%# Bind("USR_ID")%&gt;' /&gt;
                          &lt;/EditItemTemplate&gt;  
  
                           &lt;FooterTemplate&gt;
                              &lt;asp:TextBox ID="txtUSR_ID" runat="server" Width="95%"/&gt;
                          &lt;/FooterTemplate&gt;                    
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle Wrap="False" /&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField HeaderText="Name"  SortExpression="NAME"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblNAME" runat="server" Text='&lt;%# Bind("NAME")%&gt;' /&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;
                              &lt;asp:TextBox ID="txtNAME" runat="server" Width="95%" Text='&lt;%# Bind("NAME")%&gt;'/&gt;
                          &lt;/EditItemTemplate&gt;        
  
                          &lt;FooterTemplate&gt;
                              &lt;asp:TextBox ID="txtNAME" runat="server" Width="95%"/&gt;
                          &lt;/FooterTemplate&gt;
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle Wrap="False" /&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField HeaderText="Email"  SortExpression="EMAIL"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblEMAIL" runat="server" Text='&lt;%# Bind("EMAIL")%&gt;' /&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;
                              &lt;asp:TextBox ID="txtEMAIL" runat="server" Width="95%"  Text='&lt;%# Bind("EMAIL")%&gt;'/&gt;
                          &lt;/EditItemTemplate&gt;        
  
                          &lt;FooterTemplate&gt;
                              &lt;asp:TextBox ID="txtEMAIL" runat="server" Width="95%"/&gt;
                          &lt;/FooterTemplate&gt;
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle Wrap="False" /&gt;
                      &lt;/asp:TemplateField&gt; 
                      &lt;asp:TemplateField HeaderText="Active"  SortExpression="ACTIVE"&gt;
                          &lt;ItemTemplate&gt;
                               &lt;asp:CheckBox ID="chkACTIVE"  runat="server" Checked ='&lt;%# Bind("ACTIVE")%&gt;' Enabled="false"   /&gt;
                          &lt;/ItemTemplate&gt;
  
                          &lt;EditItemTemplate&gt;
                              &lt;asp:CheckBox  ID="chkACTIVE" runat="server" Width="95%" Checked ='&lt;%# Bind("ACTIVE")%&gt;'/&gt; 
                          &lt;/EditItemTemplate&gt;        
  
                          &lt;FooterTemplate&gt;
                              &lt;asp:CheckBox  ID="chkACTIVE" runat="server" Width="95%"/&gt;
                          &lt;/FooterTemplate&gt;
  
                          &lt;HeaderStyle Wrap="False" /&gt;
                          &lt;ItemStyle HorizontalAlign="Center"  Wrap="False"/&gt; 
                      &lt;/asp:TemplateField&gt;                                                                                                  
                  &lt;/Columns&gt;
                 &lt;EmptyDataTemplate&gt;
                      &lt;div style="height:315px;border-style:hidden;" &gt;
                          &lt;table class="table" &gt;
                              &lt;tr&gt;
                                  &lt;td style="padding:5px;" &gt;
                                      &lt;img id="Img1" style="height:24px;width:24px; "  runat="server" src="images/no_data_64x64.png" /&gt;    
                                  &lt;/td&gt;
                                  &lt;td style="padding:5px;font-size:large;"&gt;
                                       &lt;b&gt;No data found.&lt;/b&gt;
                                  &lt;/td&gt; 
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/div&gt;  
                  &lt;/EmptyDataTemplate&gt;
  
                  &lt;PagerStyle CssClass="pgr" /&gt;
                  &lt;AlternatingRowStyle CssClass="alt"  /&gt;
                  &lt;FooterStyle HorizontalAlign="Center" /&gt;
                  &lt;EmptyDataRowStyle CssClass="EmptyData" /&gt;
                &lt;/asp:GridView&gt;
            &lt;/div&gt;                                        
  
         &lt;%-- Picker--%&gt;
  
         &lt;cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
          &lt;/cc1:ToolkitScriptManager&gt;
  
  
         &lt;cc1:ModalPopupExtender   runat="server" TargetControlID="hdControl" ID="mdlEmpListProcess"  PopupControlID="empPanel" CancelControlID="btnClose"  OnCancelScript="getFlickerSolved();" &gt;
         &lt;/cc1:ModalPopupExtender&gt;
  
        &lt;asp:HiddenField runat="server" ID="hdControl" /&gt;
        &lt;asp:Panel runat="server" ID="empPanel"  Width="909px" Height="300"  BorderStyle="Ridge" BorderColor="Gray" Style="display:none;" BackColor="Control"&gt;
  
         &lt;table&gt;
                       &lt;tr&gt;
                          &lt;td&gt;
                              &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;
                              &lt;asp:TextBox runat="server" id="txtEmpName" CssClass="textbox" Width="240"&gt;&lt;/asp:TextBox&gt;
                              &amp;nbsp;&lt;asp:Button runat="server" ID="btnSearchEmp" CssClass="button" Text="SEARCH" OnClientClick="getFlickerSolved();"/&gt;
                                     &lt;asp:Button runat="server" ID="btnClose" CssClass="button" Text="CLOSE" /&gt;
                          &lt;/td&gt;
                       &lt;/tr&gt;
         &lt;/table&gt;   &amp;nbsp;&lt;br /&gt;
             &amp;nbsp; &amp;nbsp;
          &lt;div style="overflow:scroll; width:882px; height:233px;"&gt; 
                             &lt;asp:GridView runat="server" ID="grdEmpName"   Width="863px" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" Height="35px" GridLines="Vertical"&gt;
                                  &lt;Columns&gt;
                                          &lt;asp:TemplateField&gt;
                                                  &lt;ItemTemplate&gt;
                                                          &lt;asp:RadioButton runat="server" ID="optEmp" AutoPostBack="true" _CommandArgument= "Select" OnCheckedChanged="selectedEmployee" /&gt;
                                                  &lt;/ItemTemplate&gt;
                                          &lt;/asp:TemplateField&gt;
                                          &lt;asp:BoundField DataField="USR_ID" HeaderText="USER ID"/&gt;
                                          &lt;asp:BoundField DataField="NAME"  HeaderText="NAME"/&gt;
                                          &lt;asp:BoundField DataField="EMAIL" HeaderText="EMAIL ADDRESS"&gt;  
                                              &lt;HeaderStyle Width="300px" /&gt;
                                          &lt;/asp:BoundField&gt;        
                                  &lt;/Columns&gt;
                                 &lt;RowStyle CssClass="rowStyle" /&gt;
                                 &lt;HeaderStyle CssClass="headerStyle" BackColor="Black" Font-Bold="True" ForeColor="White" /&gt;
                                 &lt;FooterStyle BackColor="#CCCCCC" /&gt;
                                 &lt;PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /&gt;
                                 &lt;SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /&gt;
                                 &lt;AlternatingRowStyle BackColor="#CCCCCC" /&gt;
                            &lt;/asp:GridView&gt;        
           &lt;/div&gt;
            &lt;/asp:Panel&gt;
  
           &lt;%-- End Picker--%&gt;
  </code></pre>
  
  <p>Now, here's my code for <code>selectedEmployee</code> (Radio Button)</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Sub selectedEmployee(ByVal sender As Object, ByVal e As System.EventArgs)
  
      Dim lnBTNDone As RadioButton = DirectCast(sender, RadioButton)
      Dim row As GridViewRow = DirectCast(lnBTNDone.NamingContainer, GridViewRow)
  
      Dim RowIndex As Integer = gvUser.EditIndex
      Dim dt As New DataTable
  
      dt = TryCast(Session("dbCache_User"), DataView).Table.Copy
      dt.AcceptChanges()
  
      Dim dv As New DataView(dt, "", "USR_IDNTY", DataViewRowState.OriginalRows)
      Dim s As String = TryCast(gvUser.Rows(RowIndex).FindControl("lblUSR_IDNTY"), Label).Text
      Dim idx As Integer = dv.Find(s)
  
      If idx = -1 Then
          Console.WriteLine("Not Found")
  
      Else
  
          dv(idx)("USR_ID") = row.Cells(1).Text
          dv(idx)("NAME") = row.Cells(2).Text
          dv(idx)("EMAIL") = row.Cells(3).Text
  
      End If
  
      gvUser.DataSource = dv
      gvUser.DataBind()
  
      Me.mdlEmpListProcess.Hide()
  
  End Sub
  </code></pre>
  
  <p>I'm debugging the program to check if value is passing and then when I pass to NAME and Email, I've encounter this error</p>
  
  <blockquote>
    <p>system.data.dataexception was unhandled by user code. Cannot set NAME
    when passing the value.</p>
  </blockquote>
  
  <pre class="lang-vb prettyprint-override"><code>dv(idx)("NAME") = row.Cells(2).Text
  </code></pre>
  
  <p>What did I do wrong?</p>