We help IT Professionals succeed at work.
Get Started

Reference a selected rows column value from a gridview in VB .Net 3.5

731 Views
Last Modified: 2013-12-20
I've been pulling my hair out for hours, so hoping someone can point me in the right direction. I cannot seem to find how to reference the text value of a cell of a selected row in a gridview using VB. Here is what I've attempted so far:

Below is what I have in code behind, which runs without error but when I click the GridView's edit it returns a null value. I thought this to be a binding issue so I setup a binding method for the gridview so I could manually bind before or after returning the column value, but where ever I placed the binding method it always returned a null value.

    Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
        Dim MyCellValue As String
       MyCellValue = GridView1.Rows(e.NewEditIndex).Cells(1).Text
'Textbox used to display contents of selected gridview column
MyTextBox.Text = MyCellValue

    End Sub
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE