title: Select row should not include the first column datagridview asp.net
body: <p>I would like the select rowdatabound not to included the first colunm. The reason for it is when i click on expand the datagridview the page refreshes causing the datagridview row to collapse again.<br>
  Here is a image of my table I have circuled in red the column I would like to remove from the rowdatabound.
  <a href="https://i.stack.imgur.com/266uv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/266uv.png" alt="My current Datagridview"></a></p>
  
  <p>Here is my code for OnRowDataBound</p>
  
  <pre><code>    protected void OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvInventario, "Select$" + e.Row.RowIndex);
              e.Row.ToolTip = "Haga clic para seleccionar esta fila.";
          }
      }
  </code></pre>
  
  <p>And here is my aspx code:</p>
  
  <pre><code>   &lt;asp:GridView ID="gvInventario" runat="server" AutoGenerateColumns="false"  AllowSorting="true" ShowFooter="false" DataKeyNames="componente_id, ubicacion_id"
                  ShowHeaderWhenEmpty="true" AllowPaging="True" OnPageIndexChanging="gridView_PageIndexChanging" OnRowDataBound = "OnRowDataBound" OnSelectedIndexChanged = "OnSelectedIndexChanged" 
                   CellPadding="3"  AllowColumResize="True" onsorting="grdDetails_Sorting" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"&gt;    
                  &lt;Columns&gt;
                        &lt;asp:TemplateField ItemStyle-Width="20px"&gt;
                      &lt;ItemTemplate &gt;
                          &lt;a href="JavaScript:divexpandcollapse('div&lt;%# Eval("componente_id") %&gt;');" &gt;
                              &lt;img id="imgdiv&lt;%# Eval("componente_id") %&gt;" width="9px" border="0" src="../images/plus.gif"
                                  alt="" /&gt;&lt;/a&gt;                       
                      &lt;/ItemTemplate&gt;
                      &lt;ItemStyle Width="20px" VerticalAlign="Middle"&gt;&lt;/ItemStyle&gt;
                  &lt;/asp:TemplateField&gt;
  
                      &lt;asp:TemplateField HeaderText="Min" SortExpression="cantidad_mini"&gt;
                          &lt;ItemTemplate&gt;
                           &lt;asp:Label Text='&lt;%# Eval("cantidad_mini") %&gt;' runat="server" /&gt; 
                          &lt;/ItemTemplate&gt;
                          &lt;EditItemTemplate&gt;
                             &lt;asp:TextBox ID="txtQuantityMin" Text='&lt;%# Eval("cantidad_mini") %&gt;' runat="server" /&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  
                  &lt;/Columns&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I would like the first column not to be included in rowdatabound.</p>