title: Fetching Data in GridView Cells/Column
body: <p>I am a newbie in VB.net(programming). I need your advice regarding Gridview control.</p>
  
  <p>I have a gridview loaded with two columns-one column(Name)is with some Text,another(Price) is empty. </p>
  
  <p>I have got a TextBox with the data of Name and Price.</p>
  
  <p>Now,I would like to loop through the Textbox,and see if the Data/symbols of the Column(Name) of GridView Control matches with the Data in Textbox. </p>
  
  <p>If the Names of the GridView’s First Column’s data matches with the names of the Textbox,then the Price data should be fetched in the Second Column(Price) of GridView.</p>
  
  <p>To make it more clear,say :</p>
  
  <p>I have the following data in Textbox :</p>
  
  <p>Name- Price</p>
  
  <p>AB- 50</p>
  
  <p>DE- 80</p>
  
  <p>And I have two columns in GridView with following setups :</p>
  
  <p>Name(column1) – Price(column2)</p>
  
  <p>AB- Empty<br>
  DE- Empty</p>
  
  <p>Now,how can I get the Price Data of Textbox,and fetch them into the Column2 of Gridview matching the Names of Column1. So,the output in GridView should be :</p>
  
  <p>Name(column1) – Price(column2)</p>
  
  <p>AB- 50<br>
  DE- 80</p>
  
  <p>So far,I have been able to just loop through the first column of GridView…..I’m not sure how to get the data from Textbox and fetch the data into Column2 of GridView.</p>
  
  <p>Any suggestion would be highly appreciated.</p>
  
  <blockquote>
    <p>Public Class Form1</p>
  
  <pre><code>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
      'Data of GridView
      Dim dt As New DataTable()
      dt.Columns.Add("Name")
      dt.Columns.Add("Price")
      dt.Rows.Add(New [Object]() {"AB"})
      dt.Rows.Add(New [Object]() {"DE"})
      Me.DataGridView1.DataSource = dt
  
  
      'Data of Textbox
      TextBox1.Text = "AB, 50" &amp; vbNewLine &amp; "DE, 100"
  
  
  End Sub
  
  
  
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      'loop through the gridview
      Dim marketvalue As String
      For Each r As DataGridViewRow In Me.DataGridView1.Rows
          marketvalue = r.Cells(0).Value
          MessageBox.Show(marketvalue)
      Next
  End Sub End Class
  </code></pre>
  </blockquote>