• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

Obtaining Text from GridView Text Box in edit mode from RowUpdating event.

I am trying to obtain Text from GridView Text Box in edit mode from RowUpdating event. I tried to use a posted solution:

CType(e.Row.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text

I get the following error...
Error      3      'Row' is not a member of 'System.Web.UI.WebControls.GridViewUpdateEventArgs'.

The example posted used "ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs" and somehow resolved this.... I am using .NET 2.0

Also, I am doing this from a constructed data set and not directly to a database!

4 Solutions
Can you try this:

Ctype(yourGridName.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text

pauljcaronAuthor Commented:
I tried the suggested line which resulted in a cast exception. I changed TextBox to Label and retrieved the original value. Not sure where to go from here since the TextBox is in the display.
You may have to play around with the indexes of the cells and controls to get a handle to the textbox.  Usually the Gridviw puts a label, a text, and another label in each cell.
Perhaps you want to tell us the problem you are facing, not focus on the solution you think that will work.....
We may be able to help you further then....

Can you post your code and what you want to do with it?
Why don't you try using the FindControl() method and see if your textbox is there:

TextBox tb = CType(yourGridName.Rows(e.RowIndex).FindControl("<id_of_your_textBox>"), TextBox)

if(tb != null)
    //Textbox is found.
    //Do processing stuff here.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now