title: How to store value in hyperlink link selected row in gridview asp.net C#?
body: <p>I have a gridview.I have a hyperlink field and I want that when I click on hyperlink field, then row value is store in session and page redirect to other page. How can I do this?</p>
  
  <p>Here is my aspx markup:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" Height="36px" 
      style="margin-left: 270px; margin-top: 92px" Width="232px" CellPadding="3" 
      BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" 
      BorderWidth="1px" onrowcancelingedit="GridView1_RowCancelingEdit" 
      onrowediting="GridView1_RowEditing" onrowupdated="GridView1_RowUpdated" 
      onrowupdating="GridView1_RowUpdating" AutoGenerateColumns="False" 
      onrowdeleting="GridView1_RowDeleting"&gt;
      &lt;Columns&gt;
  
          &lt;asp:TemplateField HeaderText="Table Name"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txtTBL" runat="server" Text='&lt;%# Eval("Table_Name") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/EditItemTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Eval("Table_Name") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
  
          &lt;asp:CommandField HeaderText="Operation" ShowEditButton="True" 
              ShowDeleteButton="True" /&gt;
  
          &lt;asp:TemplateField&gt;
          &lt;ItemTemplate&gt;
             &lt;asp:HyperLink  Text="Select" ID="lnkSelect" runat="server" CommandName="Select" /&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
  
      &lt;/Columns&gt;
      &lt;FooterStyle BackColor="White" ForeColor="#000066" /&gt;
      &lt;HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /&gt;
      &lt;RowStyle ForeColor="#000066" /&gt;
      &lt;SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /&gt;
      &lt;SortedAscendingCellStyle BackColor="#F1F1F1" /&gt;
      &lt;SortedAscendingHeaderStyle BackColor="#007DBB" /&gt;
      &lt;SortedDescendingCellStyle BackColor="#CAC9C9" /&gt;
      &lt;SortedDescendingHeaderStyle BackColor="#00547E" /&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And here is my code behind :</p>
  
  <pre><code>public partial class DisplayTable : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
           if (!Page.IsPostBack)
           {
               // Retrieve database gridview
               gettable();
           }
      }
  
      public void gettable()
      {
          // here is code 
      } 
  
      //here all code included regarding to edit,delete etc
      protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
      {
          string s = ((HyperLink)GridView1.SelectedRow.Cells[0].Controls[0]).Text;
          Session["destype"] = s;
          Page.Response.Redirect("home.aspx");
      }
  
      public override void VerifyRenderingInServerForm(Control control)
      {
          // base.VerifyRenderingInServerForm(control);
      }
  }
  </code></pre>