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

Getting the row values in DeleteCommandEvent

4 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jocelyn
Top achievements
Rank 1
Jocelyn asked on 16 Feb 2012, 05:20 PM
Hi,

I have a RadGrid binded to a DataTable and I have a DeleteButton on each row that fires DeleteCommand event. But how can I get my current row values inside the DeleteCommand event?

Thanks

4 Answers, 1 is accepted

Sort by
0
Jocelyn
Top achievements
Rank 1
answered on 16 Feb 2012, 08:46 PM
Sorry I miss formulate my question.

I can get the value of the row by this:

Dim edit = TryCast(e.Item, GridDataItem)
Dim oldValues As New Hashtable()
e.Item.OwnerTableView.ExtractValuesFromItem(oldValues, edit)

But I only get editable values with this and I need the value of the "primary key" of my row that is ReadOnly. So how can I get it ?

Sorry for my bad english.

Edit: Here is my answer ForceExtractValue="Always" in the GridBoundColumn

Thanks
0
Accepted
Casey
Top achievements
Rank 1
answered on 16 Feb 2012, 09:09 PM
Hi Jocelyn,

You should be able to access the values in the OnDeleteCommand event of the RadGrid. I used a code converter for VB, so hopefully it converted properly... 

Protected Sub RadGrid1_DeleteCommand(sender As Object, e As GridCommandEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
        Dim val As [String] = dataItm("ColumnUniqueName").Text
    End If
End Sub


I hope this helps!
Casey
0
Jocelyn
Top achievements
Rank 1
answered on 16 Feb 2012, 09:14 PM
Thank you Casey! I was looking for something simple like that!
0
Casey
Top achievements
Rank 1
answered on 16 Feb 2012, 09:16 PM
You are welcome! Glad I could help!
Tags
Grid
Asked by
Jocelyn
Top achievements
Rank 1
Answers by
Jocelyn
Top achievements
Rank 1
Casey
Top achievements
Rank 1
Share this question
or