locked
Gridview updated row capture cell value RRS feed

  • Question

  • User1028962535 posted

    Hello

    I have a gridview that contains several columns, one of which is a phone number, I need to capture the number and place it in a textbox, when the update button is clicked.
    Can someone help me with the syntax for this please, tried this but it's not working, also is it possible to capture the cell value, if the columns is made not visible. How would I do that?

    thanks for any help..

    Protected Sub GridView1_RowUpdated(sender As Object, e As GridViewUpdatedEventArgs)

    Dim rowIndex As Integer = GridView1.EditIndex
    TextBox1.Text = GridView1.Rows(rowIndex).Cells(3).Text

    End Sub

    Sunday, June 10, 2018 2:28 PM

Answers

  • User-330142929 posted

    Hi Dan5,

    Okay this works, but how do I get it to work if the column is made 'not visible'

    According to your description, you want to capture the old values when we trigger the update event handler.

    For general bound column data, we could get the new value or old value by the code below.

            TextBox1.Text = e.OldValues("Name")
            TextBox1.Text += e.NewValues("Name")

    For template columns, use databound controls. We could use the following codes.

    TextBox1.Text = DirectCast(GridView1.Rows(e.RowIndex).Cells(3).FindControl("txtIDprice"), TextBox).Text

    If the solution could not solve your problem, please feel free to let me know.

     

    Best Regards,

    Abraham

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 12, 2018 9:41 AM

All replies

  • User1028962535 posted

    Okay this works, but how do I get it to work if the column is made 'not visible'

    Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs)

    TextBox1.Text = DirectCast(GridView1.Rows(e.RowIndex).Cells(3).Controls(0), TextBox).Text

    End Sub

    Sunday, June 10, 2018 2:45 PM
  • User-330142929 posted

    Hi Dan5,

    Okay this works, but how do I get it to work if the column is made 'not visible'

    According to your description, you want to capture the old values when we trigger the update event handler.

    For general bound column data, we could get the new value or old value by the code below.

            TextBox1.Text = e.OldValues("Name")
            TextBox1.Text += e.NewValues("Name")

    For template columns, use databound controls. We could use the following codes.

    TextBox1.Text = DirectCast(GridView1.Rows(e.RowIndex).Cells(3).FindControl("txtIDprice"), TextBox).Text

    If the solution could not solve your problem, please feel free to let me know.

     

    Best Regards,

    Abraham

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 12, 2018 9:41 AM
  • User1028962535 posted

    Thank you..

    Tuesday, June 12, 2018 2:21 PM