This is a migrated thread and some comments may be shown as answers.

Grid update command id

4 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jibber4568
Top achievements
Rank 1
Jibber4568 asked on 26 Jul 2011, 12:30 PM
I'm trying to pull the data from the Id column of the selected row within the update command as follows 
Protected Sub radgrid_Update(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles radgrid.UpdateCommand
 
        Dim selectedRow As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
        Dim rowNo As Integer = selectedRow.ItemIndex
        Dim id As String = selectedRow.Item("id").Text
 
 
       
    End Sub

This allows me to get the row index but not the data within the id column.

Any suggestions are greatly appreciated.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Jul 2011, 01:09 PM
Hello Jibber,

I suppose you want to access the updated value in UpdateCommand. Try the following code snippet to achieve this.

VB:
Protected Sub RadGrid1_UpdateCommand(sender As Object, e As GridCommandEventArgs)
    Dim editItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
    Dim newValues As New Hashtable()
    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editItem)
    Dim id As String = newValues("id").ToString()
End Sub

Thanks,
Princy.
0
Jibber4568
Top achievements
Rank 1
answered on 26 Jul 2011, 01:44 PM
Hey, thanks for reply.

Not quite, I'm just trying to get the Id stored against the row.

I can achieve it in the edit command as follows:

Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
 
        Dim rowNo As Integer = selectedRow.ItemIndex
        Dim id As Integer = selectedRow.Item("id").Text

However within the update command it will successfully obtain the row index, but not the value stored against the id field.
0
Jibber4568
Top achievements
Rank 1
answered on 10 Aug 2011, 12:46 PM
Was wondering if anyone has an update on this. Still don't seem to be able to obtain data from the initial row when it goes into edit mode.

Thanks
0
Princy
Top achievements
Rank 2
answered on 10 Aug 2011, 01:16 PM
Hello Jibber,

You can try the following code snippet to achieve your scenario.
VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
        Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim txt As TextBox = DirectCast(item("id").Controls(0), TextBox)
        Dim value As String = txt.Text
    End If
End Sub

Thanks,
Princy.
Tags
Grid
Asked by
Jibber4568
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jibber4568
Top achievements
Rank 1
Share this question
or