title: C# read data from gridView to string
body: <p>Hey I have a gridView and I would like to extract the PhotoPath (ftppath + filename (ftp://192.168.1.2/Jelly.jpg))</p>
  
  <p>its in asp.net and I'm not sure how to retrieve the data ive set the gridView up for selection and I like to "upon" select store the PhotoPath in a string.</p>
  
  <p>source</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
          AutoGenerateColumns="False" DataKeyNames="StudentID" 
          DataSourceID="SqlDataSource1" Height="263px" Width="915px" 
          AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" 
          onselectedindexchanged="GridView1_SelectedIndexChanged"&gt;
          &lt;AlternatingRowStyle BackColor="White" /&gt;
          &lt;Columns&gt;
              &lt;asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                  ShowSelectButton="True" /&gt;
              &lt;asp:BoundField DataField="No" HeaderText="MatricNo" 
                  SortExpression="MatricNo" /&gt;
              &lt;asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                  SortExpression="FirstName" /&gt;
              &lt;asp:BoundField DataField="LastName" HeaderText="LastName" 
                  SortExpression="LastName" /&gt;
              &lt;asp:BoundField DataField="Current" HeaderText="CurrentModules" 
                  SortExpression="CurrentModules" /&gt;
              &lt;asp:BoundField DataField="PhotoPath" HeaderText="PhotoPath" 
                  SortExpression="PhotoPath" /&gt;
          &lt;/Columns&gt;
          &lt;EditRowStyle BackColor="#2461BF" /&gt;
          &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
          &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
          &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt;
          &lt;RowStyle BackColor="#EFF3FB" BorderColor="Blue" BorderStyle="Solid" 
              Font-Size="Small" /&gt;
          &lt;SelectedRowStyle BackColor="#D1DDF1" BorderStyle="Solid" Font-Bold="True" 
              Font-Size="Small" ForeColor="#333333" HorizontalAlign="Center" /&gt;
          &lt;SortedAscendingCellStyle BackColor="#F5F7FB" /&gt;
          &lt;SortedAscendingHeaderStyle BackColor="#6D95E1" /&gt;
          &lt;SortedDescendingCellStyle BackColor="#E9EBEF" /&gt;
          &lt;SortedDescendingHeaderStyle BackColor="#4870BE" /&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I tryed this:</p>
  
  <pre><code>        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
      {
          string PhotoPath;
          GridView1.CurrentRow.Cells[0].Value.ToString();
      }
  </code></pre>
  
  <p>But current row isn't part of the definition.</p>